SQLITE_CONSTRAINT_CHECK
SQLiteERRORNotableConstraintofficial confidence

CHECK constraint failed

Production Risk

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
  1. 1Inserting or updating a row where the value does not satisfy a CHECK constraint.
  2. 2Application logic allowing out-of-range values to reach the database.
How to reproduce

INSERT or UPDATE violating a CHECK constraint.

trigger — this will error
trigger — this will error
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 > 0

expected output

sqlite3.IntegrityError: CHECK constraint failed: price > 0

Fix 1

Fix 2

Fix 3

Sources
Official documentation ↗

sqlite3.h — SQLITE_CONSTRAINT_CHECK = 275

SQLite CHECK constraints

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All SQLite errors