# SQLite: cannot start a transaction within a transaction

**Code:** `transaction` · **Category:** SQL · **Seen on:** SQLite, Python, Node.js

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

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

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/sql/sqlite-cannot-start-transaction-within-transaction)
