sqlite3.IntegrityError: UNIQUE constraint failed: users.email
An insert/update duplicated a value in a UNIQUE or PRIMARY KEY column in SQLite.
Seen on:
SQL
Meaning
The message names table.column. Use INSERT … ON CONFLICT DO UPDATE/NOTHING (SQLite 3.24+) for upserts.
Common causes
- Duplicate value
- Re-running seeds
- Missing upsert logic
⚡ Quick fix
- Catch the error and report “already exists”
- Use ON CONFLICT(email) DO UPDATE
Detailed fix by platform
SQL
INSERT INTO users(email, name) VALUES (?, ?) ON CONFLICT(email) DO UPDATE SET name = excluded.name;
How to diagnose
- Column — Which one?
- Data — Existing row?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026