SQLITE_READONLY_CANTINIT
SQLiteERRORNotableRead-Onlyofficial confidence
Read-only: unable to initialise shared memory
Production Risk
Medium — read-only access fails until -shm is initialised.
What this means
SQLITE_READONLY_CANTINIT (1288) is returned when a read-only connection is unable to initialise the WAL-mode shared memory (-shm file), because initialisation would require a write.
Why it happens
- 1WAL-mode database opened read-only where -shm file does not yet exist.
- 2First connection to a WAL database is read-only and cannot create -shm.
How to reproduce
Read-only open of a WAL-mode database when -shm initialisation is needed.
trigger — this will error
trigger — this will error
import sqlite3
# Open WAL database read-only with no existing -shm:
conn = sqlite3.connect('file:wal.db?mode=ro', uri=True)
conn.execute('SELECT 1') # may raise SQLITE_READONLY_CANTINITexpected output
sqlite3.OperationalError: attempt to write a readonly database
Fix 1
Fix 2
Sources
Official documentation ↗
sqlite3.h — SQLITE_READONLY_CANTINIT = 1288
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev