transaction SQL Origin: Data OSI layer 7 · Application Last updated 18 Nov 2026

SQLite: cannot start a transaction within a transaction

BEGIN was issued while a transaction was already open on the same connection.

Exact message you may see 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
Seen on: SQLite Python Node.js

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

  1. Use SAVEPOINT for nesting
  2. Let the driver manage transactions, or set isolation_level=None and manage manually
  3. Always COMMIT/ROLLBACK

Detailed fix by platform

SQL

  1. sql
    SAVEPOINT sp1;
    -- work
    RELEASE sp1;   -- or ROLLBACK TO sp1;

How to diagnose

  1. BEGIN — Nested?
  2. Driver — Implicit transactions?
  3. 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:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

266 — SQL Server Msg 266: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements (SQL)2663902 — SQL Server Msg 3902: The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION (SQL)3902COMMIT — Changes disappear: transaction never committed (autocommit off, missing COMMIT) (SQL)COMMITcontention — Firestore: 10 ABORTED: Too much contention on these documents. Please try again. (Google Cloud / Firebase)contentiondatabase or disk is full — SQLite: database or disk is full (SQLITE_FULL) (SQL)database or disk is f…datatype mismatch — SQLite: datatype mismatch (SQLITE_MISMATCH) (SQL)datatype mismatchDeadlock — Deadlock found when trying to get lock; try restarting transaction (SQL)Deadlockdisk I/O error — SQLite: disk I/O error (SQLITE_IOERR) (SQL)disk I/O errortransacti…

Explore the map of this error Full error map →

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