SQLITE_CONSTRAINT_DATATYPE
SQLiteERRORNotableConstraintofficial confidence
Strict table datatype constraint failed
Production Risk
Low — fails immediately with a clear type mismatch message.
What this means
SQLITE_CONSTRAINT_DATATYPE (3091) is returned when a value inserted into a STRICT table does not match the declared column type. STRICT tables enforce rigid type checking unlike standard SQLite tables.
Why it happens
- 1Inserting a TEXT value into an INTEGER column of a STRICT table.
- 2Inserting a non-numeric value into a REAL or NUMERIC column of a STRICT table.
How to reproduce
INSERT or UPDATE on a STRICT table with a type mismatch.
trigger — this will error
trigger — this will error
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t(x INTEGER, y TEXT) STRICT')
try:
conn.execute("INSERT INTO t VALUES('not-a-number', 'ok')")
except sqlite3.IntegrityError as e:
print(e) # cannot store TEXT value in INTEGER column t.xexpected output
sqlite3.IntegrityError: cannot store TEXT value in INTEGER column t.x
Fix 1
Fix 2
Fix 3
Version notes
Sources
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev