Error code

SQLite SQLITE_CONSTRAINT_FOREIGNKEY

SQLITESQLITE_CONSTRAINT_FOREIGNKEY
Database Error Code· An error code returned by a database server such as PostgreSQL or MySQL.

What it means

FOREIGN KEY constraint failed — the referenced row does not exist.

How to fix it

  1. Enable foreign key enforcement with PRAGMA foreign_keys=ON (off by default).
  2. Insert or verify the parent row exists before inserting the child row.
  3. Delete child rows before removing the parent.

Not affiliated with SQLite. Answer summarized from the manufacturer's manual linked above; consult that source for the authoritative procedure.