SQLite: cannot start a transaction within a transaction
BEGIN was issued while a transaction was already open on the same connection.
cannot start a transaction within a transactionsqlite3.OperationalError: cannot start a transaction within a transactionSQLITE_ERROR: cannot start a transaction within a transactioncannot commit - no transaction is active Meaning
SQLite doesn't nest transactions; use SAVEPOINT name / RELEASE for nested work. In Python's sqlite3, implicit transactions and a manual BEGIN collide; set isolation_level=None for manual control or avoid explicit BEGIN.
Common causes
- Nested BEGIN
- Driver implicit BEGIN plus manual BEGIN
- Exception left a transaction open
- Shared connection across code paths
- Missing COMMIT/ROLLBACK
⚡ Quick fix
- Use SAVEPOINT for nesting
- Let the driver manage transactions, or set
isolation_level=Noneand manage manually - Always COMMIT/ROLLBACK
Detailed fix by platform
SQL
- sql
SAVEPOINT sp1; -- work RELEASE sp1; -- or ROLLBACK TO sp1;
How to diagnose
- BEGIN — Nested?
- Driver — Implicit transactions?
- Rollback — On error?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 266 SQL Server Msg 266: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements
- 3902 SQL Server Msg 3902: The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION
- COMMIT Changes disappear: transaction never committed (autocommit off, missing COMMIT)
Most viewed in SQL
- ORA-00933 ORA-00933: SQL command not properly ended
- readonly database sqlite3.OperationalError: attempt to write a readonly database
- pool timeout Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. All pooled connections were in use and max pool size was reached.
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 18 Nov 2026