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).
94
votes
You should mark the highest voted answer below as the answer.
- Fmstrat
I beg to differ. OP should accept the answer which answered his question and helped him. All too often, that is not the most popular answer, and occasionally the most popular answer is flat out wrong.
- Mawg says reinstate Monica
9 Answers
138
votes
92
votes
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
26
votes
4
votes
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.
2
votes
1
votes
0
votes
0
votes
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.