SQLite UNIQUE failed SQL Origin: Data Last updated 13 Oct 2026

sqlite3.IntegrityError: UNIQUE constraint failed: users.email

An insert/update duplicated a value in a UNIQUE or PRIMARY KEY column in SQLite.

Exact message you may see UNIQUE constraint failed
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 not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

1062 — MySQL ERROR 1062 (23000): Duplicate entry for key (MySQL)106223505 — PostgreSQL: ERROR: duplicate key value violates unique constraint (PostgreSQL)235052627 — SQL Server: Violation of PRIMARY KEY constraint 'x'. Cannot insert duplicate key in object 'y'. (Msg 2627) (SQL)2627ALREADY_EXISTS — API Error: Resource already exists (ALREADY_EXISTS / resource_already_exists / 409) (API)ALREADY_EXISTSDbUpdateException — DbUpdateException: An error occurred while saving the entity changes. See the inner exception for details. (.NET)DbUpdateExceptionORA-00001 — ORA-00001: unique constraint (SCHEMA.PK_X) violated (SQL)ORA-00001ORA-01400 — ORA-01400: cannot insert NULL into ("SCHEMA"."TABLE"."COLUMN") (SQL)ORA-01400readonly database — sqlite3.OperationalError: attempt to write a readonly database (SQL)readonly databaseSQLite UN…

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.