SQLITE_CORRUPT_SEQUENCE
SQLiteERRORCriticalCorruptionofficial confidence
sqlite_sequence table is corrupt
Production Risk
High — AUTOINCREMENT inserts will fail.
What this means
SQLITE_CORRUPT_SEQUENCE (523) is returned when the sqlite_sequence table (which tracks AUTOINCREMENT counters) contains invalid or inconsistent data.
Why it happens
- 1sqlite_sequence table was manually edited or corrupted.
- 2Database file corruption affecting the sqlite_sequence table.
How to reproduce
INSERT into a table with AUTOINCREMENT when sqlite_sequence is corrupt.
trigger — this will error
trigger — this will error
-- Manually corrupt sqlite_sequence (do not do in production): UPDATE sqlite_sequence SET seq = -1 WHERE name = 'orders'; -- Next INSERT into orders → SQLITE_CORRUPT_SEQUENCE
expected output
sqlite3.DatabaseError: database disk image is malformed
Fix 1
Fix 2
What not to do
✕
Version notes
Sources
Official documentation ↗
sqlite3.h — SQLITE_CORRUPT_SEQUENCE = 523
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev