How to find SQLITE database file version

喜欢而已 提交于 2019-11-26 15:47:12

问题


I have few sqlite database files. I want to know the database file version i.e if the database was created with sqlite2 or sqlite3 or any other main/sub version (not the sqlite library or driver or user_version or schema_version).


回答1:


You can write this command in any sqlite explorer which will give the sqlite version

select sqlite_version();



回答2:


You can get version number of a database file by the Magic Header String:

  • sqlite2 ==> first 48 bytes
  • sqlite3 ==> first 16 bytes

$ head -c 48 file2.db
** This file contains an SQLite 2.1 database **

$ head -c 16 file3.db
SQLite format 3

The easier way is using the file command:

$ file file2.db
file2.db: SQLite 2.x database

$ file file3.db
file3.db: SQLite 3.x database



回答3:


Get user_version: run sql: PRAGMA user_version;

Get schema_version: PRAGMA schema_version;

When create database file (.db), user_version can be set by user.




回答4:


The correct answer from version 3 of sqlite program is:

sqlite3 --version



回答5:


You can extract the information from the header file. It will require you to open the database file 'by hand' but I don't know if there is an API function to get this information.




回答6:


If you have a data connection to it in Visual Studio, you can right click on the data base in Server Explorer, select properties, and the version will be shown in the properties window, (under Version, surprisingly). You might need to left click the database first to open it.




回答7:


You have to open the python shell then write these steps:

import sqlite3

sqlite3.sqlite_version



回答8:


Check manual file

sqlite3.version The version number of this module, as a string. This is not the version of the SQLite library.

sqlite3.version_info The version number of this module, as a tuple of integers. This is not the version of the SQLite library.

sqlite3.sqlite_version The version number of the run-time SQLite library, as a string.

sqlite3.sqlite_version_info The version number of the run-time SQLite library, as a tuple of integers.




回答9:


I found this to be the easiest method to determine the version of sqlite. Run the Python IDLE Shell, then do the following:

>>> import sqlite3
>>> sqlite3.version
'2.6.0'

In my case it was 2.6.0. Hope this helps... Mark



来源:https://stackoverflow.com/questions/9646353/how-to-find-sqlite-database-file-version

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!