SQLITE_CONSTRAINT_TRIGGER
SQLiteERRORNotableConstraintofficial confidence
Constraint raised by a trigger
Production Risk
Medium — trigger validation correctly rejected the DML.
What this means
SQLITE_CONSTRAINT_TRIGGER (1811) is returned when a trigger raises a constraint violation using the RAISE() function.
Why it happens
- 1A BEFORE or AFTER trigger called RAISE(ABORT, 'message') or RAISE(FAIL, 'message').
- 2Business logic enforced via triggers rejected the DML operation.
How to reproduce
INSERT, UPDATE, or DELETE that fires a trigger containing RAISE().
trigger — this will error
trigger — this will error
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t(x)')
conn.execute("""
CREATE TRIGGER no_negatives BEFORE INSERT ON t
BEGIN
SELECT RAISE(ABORT, 'negative values not allowed')
WHERE NEW.x < 0;
END
""")
try:
conn.execute('INSERT INTO t VALUES(-1)')
except sqlite3.IntegrityError as e:
print(e) # negative values not allowedexpected output
sqlite3.IntegrityError: negative values not allowed
Fix 1
Fix 2
Sources
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev