SQLITE_CONSTRAINT_NOTNULLERRORTier 2 — Caution⚠️ MEDIUM confidenceNOT NULL constraint failed
Category: ConstraintVersions: 3.8.0+
🔴 Production Risk Error
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
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.emailsqlite3.IntegrityError: NOT NULL constraint failed: users.email
Fix 1
Why this works
Provide a non-NULL value or a default: ALTER TABLE users ALTER COLUMN email SET DEFAULT ''
Fix 2
Why this works
Add application-level validation to catch None before the INSERT.
Sources
📚 Official docs: https://www.sqlite.org/rescode.html#constraint_notnull
🔧 Source ref: sqlite3.h — SQLITE_CONSTRAINT_NOTNULL = 1299
Confidence assessment
⚠️ MEDIUM confidence
Stable.
See also
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →