sqlite-utils 4.0 folds schema migrations into the core library — the first major version bump since 3.0 in November 2020. The 124th release of Simon Willison’s SQLite toolkit ports migration logic from his standalone sqlite-migrate package and ships with breaking changes that require an upgrade guide.
The library provides both a Python API and CLI for creating and manipulating SQLite databases — utility helpers, not a full ORM.
Three features landed in 4.0:
- Database migrations — define schema change sequences in Python files; the library tracks which migrations are applied and runs any pending ones. Forward-only, no rollback path.
- Nested transactions — new
db.atomic()method for transaction nesting. - Compound foreign keys — multi-column FK constraints now supported.
The migration engine builds on table.transform(), which handles schema changes SQLite’s ALTER TABLE refuses. It implements the pattern from the SQLite docs: create a temp table with the new schema, copy data across, swap. That covers column renames, type changes, and constraint modifications — operations that normally require manual table rebuilds in raw SQLite.
NOTE
4.0 includes breaking changes beyond the new features. The upgrade guide covers the specifics — read it before bumping a pinned version.
Available now on PyPI. The migration API is a modified port of sqlite-migrate, so existing users can consolidate on one package instead of maintaining both.