SQLite error codes
All SQLite result codes from the official list, primary and extended, with the text sqlite3_errstr() returns for each primary code. The ones you are likely to meet have a full page with causes and fixes.
Reading a SQLite error
SQLite functions return an integer result code. The low eight bits are the primary code, such as SQLITE_BUSY (5). Extended codes add detail in the higher bits: SQLITE_BUSY_SNAPSHOT is 517, which is 5 + 2 × 256. Extended codes are returned when they are enabled with sqlite3_extended_result_codes() or read with sqlite3_extended_errcode().
The message a program shows usually comes from sqlite3_errmsg(), which can be more specific than the generic text, for example UNIQUE constraint failed: users.email instead of constraint failed.
Language bindings wrap these codes: Python's sqlite3 module raises OperationalError or IntegrityError and, since Python 3.11, exposes sqlite_errorcode and sqlite_errorname on the exception.
All SQLite errors in this reference
105 codes, 40 with a full write-up (linked). Codes and messages are from the SQLite result and error codes documentation.
Primary result codes
| Code | Meaning |
|---|---|
SQLITE_OK
|
0
not an error
|
SQLITE_ERROR
|
SQL logic error
1
SQL logic error
|
SQLITE_INTERNAL
|
2
|
SQLITE_PERM
|
access permission denied
3
access permission denied
|
SQLITE_ABORT
|
query aborted
4
query aborted
|
SQLITE_BUSY
|
database is locked
5
database is locked
|
SQLITE_LOCKED
|
database table is locked
6
database table is locked
|
SQLITE_NOMEM
|
out of memory
7
out of memory
|
SQLITE_READONLY
|
attempt to write a readonly database
8
attempt to write a readonly database
|
SQLITE_INTERRUPT
|
interrupted
9
interrupted
|
SQLITE_IOERR
|
disk I/O error
10
disk I/O error
|
SQLITE_CORRUPT
|
database disk image is malformed
11
database disk image is malformed
|
SQLITE_NOTFOUND
|
12
unknown operation
|
SQLITE_FULL
|
database or disk is full
13
database or disk is full
|
SQLITE_CANTOPEN
|
unable to open database file
14
unable to open database file
|
SQLITE_PROTOCOL
|
locking protocol
15
locking protocol
|
SQLITE_EMPTY
|
16
|
SQLITE_SCHEMA
|
database schema has changed
17
database schema has changed
|
SQLITE_TOOBIG
|
string or blob too big
18
string or blob too big
|
SQLITE_CONSTRAINT
|
constraint failed
19
constraint failed
|
SQLITE_MISMATCH
|
datatype mismatch
20
datatype mismatch
|
SQLITE_MISUSE
|
bad parameter or other API misuse
21
bad parameter or other API misuse
|
SQLITE_NOLFS
|
22
|
SQLITE_AUTH
|
authorization denied
23
authorization denied
|
SQLITE_FORMAT
|
24
|
SQLITE_RANGE
|
column index out of range
25
column index out of range
|
SQLITE_NOTADB
|
file is not a database
26
file is not a database
|
SQLITE_NOTICE
|
27
notification message
|
SQLITE_WARNING
|
28
warning message
|
SQLITE_ROW
|
100
another row available
|
SQLITE_DONE
|
101
no more rows available
|
Extended result codes
| Code | Meaning |
|---|---|
SQLITE_OK_LOAD_PERMANENTLY
|
256
|
SQLITE_ERROR_MISSING_COLLSEQ
|
no such collation sequence
257
no such collation sequence: unicode_ci
|
SQLITE_BUSY_RECOVERY
|
another process is recovering the WAL
261
database is locked
|
SQLITE_LOCKED_SHAREDCACHE
|
record locked in shared cache
262
database table is locked
|
SQLITE_READONLY_RECOVERY
|
264
|
SQLITE_IOERR_READ
|
266
|
SQLITE_CORRUPT_VTAB
|
267
|
SQLITE_CANTOPEN_NOTEMPDIR
|
270
|
SQLITE_CONSTRAINT_CHECK
|
CHECK constraint failed
275
CHECK constraint failed: price_positive
|
SQLITE_AUTH_USER
|
279
|
SQLITE_NOTICE_RECOVER_WAL
|
283
|
SQLITE_WARNING_AUTOINDEX
|
284
|
SQLITE_ERROR_RETRY
|
513
|
SQLITE_ABORT_ROLLBACK
|
statement aborted by ROLLBACK
516
abort due to ROLLBACK
|
SQLITE_BUSY_SNAPSHOT
|
stale read can't become a write
517
database is locked
|
SQLITE_LOCKED_VTAB
|
518
|
SQLITE_READONLY_CANTLOCK
|
520
|
SQLITE_IOERR_SHORT_READ
|
read returned fewer bytes
522
disk I/O error
|
SQLITE_CORRUPT_SEQUENCE
|
523
|
SQLITE_CANTOPEN_ISDIR
|
the path is a directory
526
unable to open database file
|
SQLITE_CONSTRAINT_COMMITHOOK
|
531
|
SQLITE_NOTICE_RECOVER_ROLLBACK
|
539
|
SQLITE_ERROR_SNAPSHOT
|
769
|
SQLITE_BUSY_TIMEOUT
|
blocking file lock timed out
773
database is locked
|
SQLITE_READONLY_ROLLBACK
|
hot journal can't be rolled back
776
attempt to write a readonly database
|
SQLITE_IOERR_WRITE
|
778
|
SQLITE_CORRUPT_INDEX
|
index entry missing
779
database disk image is malformed
|
SQLITE_CANTOPEN_FULLPATH
|
782
|
SQLITE_CONSTRAINT_FOREIGNKEY
|
FOREIGN KEY constraint failed
787
FOREIGN KEY constraint failed
|
SQLITE_READONLY_DBMOVED
|
database file moved while open
1032
attempt to write a readonly database
|
SQLITE_IOERR_FSYNC
|
1034
|
SQLITE_CANTOPEN_CONVPATH
|
1038
|
SQLITE_CONSTRAINT_FUNCTION
|
1043
|
SQLITE_READONLY_CANTINIT
|
1288
|
SQLITE_IOERR_DIR_FSYNC
|
1290
|
SQLITE_CANTOPEN_DIRTYWAL
|
1294
|
SQLITE_CONSTRAINT_NOTNULL
|
NOT NULL constraint failed
1299
NOT NULL constraint failed: users.name
|
SQLITE_READONLY_DIRECTORY
|
can't create the journal file
1544
attempt to write a readonly database
|
SQLITE_IOERR_TRUNCATE
|
1546
|
SQLITE_CANTOPEN_SYMLINK
|
1550
|
SQLITE_CONSTRAINT_PRIMARYKEY
|
PRIMARY KEY constraint failed
1555
UNIQUE constraint failed: orders.id
|
SQLITE_IOERR_FSTAT
|
1802
|
SQLITE_CONSTRAINT_TRIGGER
|
RAISE() in a trigger aborted it
1811
constraint failed
|
SQLITE_IOERR_UNLOCK
|
2058
|
SQLITE_CONSTRAINT_UNIQUE
|
UNIQUE constraint failed
2067
UNIQUE constraint failed: users.email
|
SQLITE_IOERR_RDLOCK
|
2314
|
SQLITE_CONSTRAINT_VTAB
|
2323
|
SQLITE_IOERR_DELETE
|
2570
|
SQLITE_CONSTRAINT_ROWID
|
2579
|
SQLITE_IOERR_BLOCKED
|
2826
|
SQLITE_CONSTRAINT_PINNED
|
2835
|
SQLITE_IOERR_NOMEM
|
3082
|
SQLITE_CONSTRAINT_DATATYPE
|
value doesn't fit a STRICT column
3091
cannot store TEXT value in INTEGER column t.qty
|
SQLITE_IOERR_ACCESS
|
3338
|
SQLITE_IOERR_CHECKRESERVEDLOCK
|
3594
|
SQLITE_IOERR_LOCK
|
3850
|
SQLITE_IOERR_CLOSE
|
4106
|
SQLITE_IOERR_DIR_CLOSE
|
4362
|
SQLITE_IOERR_SHMOPEN
|
4618
|
SQLITE_IOERR_SHMSIZE
|
4874
|
SQLITE_IOERR_SHMLOCK
|
5130
|
SQLITE_IOERR_SHMMAP
|
5386
|
SQLITE_IOERR_SEEK
|
5642
|
SQLITE_IOERR_DELETE_NOENT
|
5898
|
SQLITE_IOERR_MMAP
|
6154
|
SQLITE_IOERR_GETTEMPPATH
|
6410
|
SQLITE_IOERR_CONVPATH
|
6666
|
SQLITE_IOERR_VNODE
|
6922
|
SQLITE_IOERR_AUTH
|
7178
|
SQLITE_IOERR_BEGIN_ATOMIC
|
7434
|
SQLITE_IOERR_COMMIT_ATOMIC
|
7690
|
SQLITE_IOERR_ROLLBACK_ATOMIC
|
7946
|
SQLITE_IOERR_DATA
|
8202
|
SQLITE_IOERR_CORRUPTFS
|
8458
|
A faster way to work with SQLite
SQLly is a native SQL client for macOS, Windows and Linux with schema-aware IntelliSense and guardrails for risky statements.