eolas/neuron/feff9a94-f7b2-4f7c-88d4-f1e6d70cf754/SQLite.md
2024-12-09 18:23:09 +00:00

591 B

tags created
databases
SQL
SQLite
Wednesday, November 13, 2024

SQLite

Enabling foreign key constraints

Foreign key constraints are not enabled by default - it is very permissive. You must manually turn them on, as part of the connection process:

connection = sqlite3.connect("my_database.db")
connection.execute("PRAGMA foreign_keys = ON")

INSERT OR IGNORE INTO

If table has a UNIQUE constraint on a field, insert if it is unique otherwise skip without throwing a constraint error.

INSERT OR IGNORE INTO table_name (value) VALUES (:value)