The reason seems to be twisted running the queries in different threads. One solution is to launch your query as an interaction and preceed it with the pragma setting. For example, replace: d = self.dbpool.runQuery("DELETE FROM profiles WHERE name = ?", (name, )) with: def delete(txn): txn.execute("PRAGMA foreign_keys = ON") txn.execute("DELETE FROM profiles WHERE name = ?", (name,)) return None d = self.dbpool.runInteraction(delete)
Sqlite foreign keys "ON DELETE CASCADE" do not workcreated
The support of foreign keys do not seem be effective, despite "PRAGMA foreign_key = 1" is set after the initialization. Some ideas: - http://p-s.co.nz/wordpress/foreign-key-support-in-sqlite-and-python/ - if twisted adbapi opens several threads, the pragma is set only for one of them - ... ?