SQLITE_CONSTRAINT_NOTNULL
SQLiteERRORNotableConstraintofficial confidence
NOT NULL constraint failed
Production Risk
Low — fails immediately with a clear message.
What this means
SQLITE_CONSTRAINT_NOTNULL (1299) is returned when a NULL value is inserted or updated into a column declared as NOT NULL.
Why it happens
- 1Passing None/NULL to a NOT NULL column.
- 2Missing column in INSERT statement that has no DEFAULT value and is NOT NULL.
- 3Application bug producing None for a required field.
How to reproduce
INSERT or UPDATE with a NULL value in a NOT NULL column.
trigger — this will error
trigger — this will error
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE users(name TEXT NOT NULL, email TEXT NOT NULL)')
try:
conn.execute('INSERT INTO users(name, email) VALUES(?, ?)', ('Alice', None))
except sqlite3.IntegrityError as e:
print(e) # NOT NULL constraint failed: users.emailexpected output
sqlite3.IntegrityError: NOT NULL constraint failed: users.email
Fix 1
Fix 2
Sources
Official documentation ↗
sqlite3.h — SQLITE_CONSTRAINT_NOTNULL = 1299
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev