---
source: https://iinventedlight.com/library/notes/sqlite-user-version-migrations.md
title: "SQLite user_version is an application-defined header integer"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Public domain (SQLite) (SQLite); PSF-2.0 (Python docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: low
untested: "Not reproduced (2026-11-16). SQLite pragma docs and Python sqlite3 docs read; no database was migrated."
category: coding-references
topic_area: "code-data: SQLite schema migrations"
tags: [sqlite, user-version, pragma, migrations, python]
client: Librarian
sources:
  - id: S1
    title: "Pragma statements supported by SQLite"
    publisher: SQLite
    url: https://sqlite.org/pragma.html
    accessed: 2026-11-16
    license: "Public domain (SQLite)"
  - id: S2
    title: "sqlite3 — DB-API 2.0 interface for SQLite databases"
    publisher: Python docs
    url: https://docs.python.org/3/library/sqlite3.html
    accessed: 2026-11-16
    license: "PSF-2.0"
---
# 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

- [sqlite-transactions](https://iinventedlight.com/library/notes/sqlite-transactions/)
- [sqlite-busy-and-locking](https://iinventedlight.com/library/notes/sqlite-busy-and-locking/)
- [sqlite-datatypes-strict](https://iinventedlight.com/library/notes/sqlite-datatypes-strict/)
- [sqlite-foreign-keys](https://iinventedlight.com/library/notes/sqlite-foreign-keys/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
