A unique constraint requires values in a column or column group to remain distinct. A violation often signals that application code is supplying an identifier that the database should generate. section 6.1
Diagnosing a repeated question-set ID
A SQLite error reports “UNIQUE constraint failed: question_sets.question_set_id.” Checking the sessions and question_sets tables shows that sessions receive new IDs, while question sets repeatedly attempt to insert ID 1 or reuse ID 36. The practical fix is to stop inserting the ID explicitly and rely on the column’s auto-increment behavior. When an AI assistant proposes a large rewrite, inspect its diff and accept only the reviewed changes. section 6.1
sqlite3.IntegrityError: UNIQUE constraint failed: question_sets.question_set_id
Use the SQLite error listing as the starting point for tracing a uniqueness failure. section 6.1






