As per the official specification of the database format, there is a header at the beginning of the database file spanning the first 100 bytes.
There are a few items in the header that contain version numbers:
Offset Size Description
18 1 File format write version. 1 for legacy; 2 for WAL.
19 1 File format read version. 1 for legacy; 2 for WAL.
60 4 The "user version" as read and set by the user_version pragma.
92 4 The version-valid-for number.
96 4 SQLITE_VERSION_NUMBER
As per your question it looks like you want to get SQLITE_VERSION_NUMBER
.
That is actually not a "database version" (and there is not such a thing), but rather the value for the SQLite library that most recently modified the database file.
To get that value you simply have to read the 4-byte big-endian integer at offset 96.
For that sake, you can use python code here ("I welcome other means to do so.).
I tried creating a database with python code containing the lines
import sqlite3
print('sqlite3 sqlite_version: ', sqlite3.sqlite_version)
(... create database ...)
which printed
sqlite3 sqlite_version: 3.31.1
and then reading the database header with the linked code.
In particular, lines
sqlite_version_number = unpack('>i', header[96:])[0]
print('SQLITE_VERSION_NUMBER: ' + str(sqlite_version_number))
printed
SQLITE_VERSION_NUMBER: 3031001
confirming the correct reading of "the database version number" (between quotes for reasons explained above).
Notes:
This would work in both Windows and Linux, as long as you have python available.
You can find other ways of reading the header. The point is identifying where to look for the information you need.
2.1. Sqlite. I couldn't find a command that would show the required info.
2.2. Linux. dd
can do the job for you.
2.3. Powershell. [System.IO.File]
or Get-Content
can possibly help. I did not explore this further.