An integrity error signals that a database operation violates a constraint, such as uniqueness. Treat the message as a starting point: inspect the failing table, query the stored records, and verify the proposed fix. section 6.1
Repeated question-set identifiers
Refreshing the application correctly creates new sessions, but inserting a new question set raises a unique-constraint failure on question_sets.question_set_id. Inspection shows that the first question set ends at record 35; later inserts repeatedly use identifier 36 while iterating through 35 questions. The repair changes insertion so the database generates each identifier, then the result is checked by confirming that sessions contain their expected questions. section 6.1
Use a disciplined debugging sequence:
- Copy the complete error rather than relying on a short label. section 6.1
- Compare the failing constraint with actual table contents and application behavior. section 6.1
sqlite3.IntegrityError: UNIQUE constraint failed: question_sets.question_set_id
Inspect the exact SQLite message to identify the violated constraint and affected table or column. section 6.1
