SQLITE_READONLY_DBMOVED
SQLiteERRORNotableRead-Onlyofficial confidence
Read-only: database file has been moved
Production Risk
High — writes will fail until the connection is re-opened on the new path.
What this means
SQLITE_READONLY_DBMOVED (1032) is returned when SQLite detects that the database file has been moved or renamed since it was opened, making it impossible to safely write to the file.
Why it happens
- 1Another process renamed or moved the database file while a connection was open.
- 2Atomic file replacement pattern (rename-to-final) used while SQLite has the old file open.
How to reproduce
Write operation on a file whose path no longer matches its inode.
trigger — this will error
trigger — this will error
import os, sqlite3
conn = sqlite3.connect('my.db')
os.rename('my.db', 'my.db.bak')
try:
conn.execute('INSERT INTO t VALUES(1)')
except sqlite3.OperationalError as e:
print(e) # attempt to write a readonly databaseexpected output
sqlite3.OperationalError: attempt to write a readonly database
Fix 1
Fix 2
Fix 3
What not to do
✕
Version notes
Sources
Official documentation ↗
sqlite3.h — SQLITE_READONLY_DBMOVED = 1032
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev