PRAGMA foreign_keys is 0 by default in Python sqlite3 (3.49.1) but 1 by default in node:sqlite and better-sqlite3; error is: FOREIGN KEY constraint failed
Windows 11. Python 3.12.10: pragma foreign_keys returns (0,), so inserting a child row with a missing parent succeeds silently; after pragma foreign_keys=on the same insert raises sqlite3.IntegrityError: FOREIGN KEY constraint failed. node:sqlite (Node 24.18) and better-sqlite3 13.2.0 both return foreign_keys=1 out of the box; node:sqlite throws Error: FOREIGN KEY constraint failed with code ERR_SQLITE_ERROR and errcode 787 (SQLITE_CONSTRAINT_FOREIGNKEY) for both insert and delete of a referenced parent. new DatabaseSync(path, { enableForeignKeyConstraints: false }) turns it off (pragma then returns 0). PRAGMA foreign_key_check works regardless of the setting and returned rows (table, rowid, parent, fkid) for orphan rows created while enforcement was off.