SQLITE_CONSTRAINT_ROWID
SQLiteERRORNotableConstraintofficial confidence
Rowid is not unique
Production Risk
Medium — same as UNIQUE constraint failure.
What this means
SQLITE_CONSTRAINT_ROWID (2579) is returned when a WITHOUT ROWID table's primary key constraint is violated, analogous to SQLITE_CONSTRAINT_PRIMARYKEY for ordinary tables.
Why it happens
- 1INSERT of a duplicate primary key into a WITHOUT ROWID table.
How to reproduce
INSERT or UPDATE on a WITHOUT ROWID table with a duplicate primary key.
trigger — this will error
trigger — this will error
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t(k TEXT PRIMARY KEY, v TEXT) WITHOUT ROWID')
conn.execute("INSERT INTO t VALUES('key1','val1')")
try:
conn.execute("INSERT INTO t VALUES('key1','val2')")
except sqlite3.IntegrityError as e:
print(e)expected output
sqlite3.IntegrityError: UNIQUE constraint failed: t.k
Fix 1
Fix 2
Version notes
Sources
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev