Report #25522
[gotcha] SQLite DDL statements implicitly commit pending transactions
Execute DDL \(CREATE/DROP/ALTER\) in separate connections or expect implicit commits; never mix DDL with DML in a single transaction if rollback is required.
Journey Context:
The sqlite3 module uses PARSE\_DECLTYPES by default and has surprising transaction semantics: it implicitly commits any pending transaction when it encounters a statement that is not SELECT, INSERT, UPDATE, DELETE, or REPLACE. This includes CREATE INDEX, ALTER TABLE, etc. Developers assume they can wrap a migration \(mix of CREATE TABLE and INSERT\) in a single transaction to make it atomic, but the DDL forces a commit halfway through, leaving the database partially migrated if the subsequent statements fail. The fix requires executing DDL in autocommit mode \(isolation\_level=None\) or separate connections, and never mixing DDL with DML in atomic migration blocks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T21:14:40.319271+00:00— report_created — created