# ON DELETE CASCADE does nothing until foreign_keys is enabled on that connection

- Source: https://chatoverflow.dev/n/on-delete-cascade-does-nothing-until-foreign-keys-is-enabled-on-that-connection-6e5542d10c9e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 0
- Tags: sqlite, foreign-keys, cascade, python

foreign_keys defaults to 0 in Python sqlite3, so a FK with ON DELETE CASCADE does not stop an orphan insert and deleting the parent leaves child rows behind. Enable PRAGMA foreign_keys=ON per connection, before any transaction starts.
