SQLite user_version is an application-defined header integer
Answer: PRAGMA user_version gets or sets the user-version integer at offset 60 in the SQLite database header. SQLite does not use that value itself, so an application can use it as its own schema-version marker.
Do not use schema_version
schema_version is different: SQLite increments it whenever the schema changes. The SQLite docs warn that changing it can cause statements to use an obsolete schema, giving incorrect answers or database corruption. Reading it is safe.
Python transaction wrapper
Python's sqlite3 Connection works as a context manager. When the with body finishes without an exception, the transaction is committed. If the commit fails or the body raises an uncaught exception, it is rolled back.
See also
Claims
- id: C1 claim: user_version is stored at offset 60. source: S1 evidence: "user-version integer at offset 60 in the database header"
- id: C2 claim: SQLite does not use user_version itself. source: S1 evidence: "SQLite makes no use of the user-version itself."
- id: C3 claim: SQLite increments schema_version on schema change. source: S1 evidence: "SQLite automatically increments the schema-version whenever the schema changes."
- id: C4 claim: Python connections can manage transactions as context managers. source: S2 evidence: "can be used as a context manager that automatically commits or rolls back"
Sources
- [S1] Pragma statements supported by SQLite. SQLite. https://sqlite.org/pragma.html . License: Public domain (SQLite). Accessed 2026-11-16.
- [S2] sqlite3 — DB-API 2.0 interface for SQLite databases. Python docs. https://docs.python.org/3/library/sqlite3.html . License: PSF-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: SQLite, Pragma statements supported by SQLite, Public domain (SQLite) (https://sqlite.org/copyright.html); Python docs, sqlite3 — DB-API 2.0 interface for SQLite databases, PSF-2.0 (https://raw.githubusercontent.com/python/cpython/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: SQLite, Pragma statements supported by SQLite, Public domain (SQLite) (https://sqlite.org/copyright.html); Python docs, sqlite3 — DB-API 2.0 interface for SQLite databases, PSF-2.0 (https://raw.githubusercontent.com/python/cpython/main/LICENSE).
Cite this
iinventedlight. 2026. "SQLite user_version is an application-defined header integer." iinventedlight Library, iil:note:qka6ghjt, version of 2026-11-16. https://iinventedlight.com/library/notes/sqlite-user-version-migrations/. License: CC-BY-4.0.
@misc{iil_note_qka6ghjt,
author = {{iinventedlight}},
title = {{SQLite user\_version is an application-defined header integer}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/sqlite-user-version-migrations/},
note = {Permanent ID iil:note:qka6ghjt. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/sqlite-user-version-migrations.md.