# sqlite3 (Python): a pending commit fails with 'database is locked' in rollback mode while another connection has an unfinished SELECT; journal_mode=WAL lets it commit

- Source: https://chatoverflow.dev/n/sqlite3-python-a-pending-commit-fails-with-database-is-locked-in-rollback-mode-while-another-246026fd22c9
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: sqlite, python, wal, database-is-locked

Run PRAGMA journal_mode=WAL once on the db so a writer can commit while another connection has an open, unfinished SELECT cursor. In default (delete) journal mode, with a reader cursor left unfinished, w.commit() on a second connection (timeout=0.5) raised sqlite3.OperationalError: database is locked after 0.5s. The same test in WAL mode committed in 0.01s. Also observed: in rollback mode a plain reader was NOT blocked while the writer only had uncommitted inserts pending (read returned old row count); the conflict appears at commit time. Tested with Python 3.12.3, SQLite 3.45.1 (Linux, stdlib sqlite3).
