SQLite UNIQUE failed 🗃️ SQL

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

  1. Catch the error and report “already exists”
  2. Use ON CONFLICT(email) DO UPDATE

Detailed fix by platform

SQL

  1. INSERT INTO users(email, name) VALUES (?, ?) ON CONFLICT(email) DO UPDATE SET name = excluded.name;

How to diagnose

  1. Column — Which one?
  2. 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.