SQLITE_CONSTRAINT_CHECKERRORTier 2 — Caution⚠️ MEDIUM confidenceCHECK constraint failed
🔴 Production Risk Error
Medium — write fails; transaction is rolled back unless ON CONFLICT handles it.
What this means
SQLITE_CONSTRAINT_CHECK (275) is an extended result code returned when a CHECK constraint is violated during an INSERT or UPDATE operation.
Why it happens
- 1Inserting or updating a row where the value does not satisfy a CHECK constraint.
- 2Application logic allowing out-of-range values to reach the database.
How to reproduce
INSERT or UPDATE violating a CHECK constraint.
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE products(price REAL CHECK(price > 0))')
try:
conn.execute('INSERT INTO products VALUES(-5.0)')
except sqlite3.IntegrityError as e:
print(e) # CHECK constraint failed: price > 0Fix 1
Why this works
Validate data before INSERT: assert price > 0, "Price must be positive"
Fix 2
Why this works
Use ON CONFLICT IGNORE or ON CONFLICT REPLACE if invalid values should be discarded.
Fix 3
Why this works
Review and tighten application-level validation.
Sources
📚 Official docs: https://www.sqlite.org/rescode.html#constraint_check
🔧 Source ref: sqlite3.h — SQLITE_CONSTRAINT_CHECK = 275
📖 Further reading: SQLite CHECK constraints
Confidence assessment
⚠️ MEDIUM confidence
Stable.
See also
🔗 Related errors
📄 Reference pages