From c55955f42d5fff886892f5d0093ee2725a911b02 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sun, 11 Aug 2019 18:36:44 -0700 Subject: Set sqlite to respect foreign key constraints --- youtube/subscriptions.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'youtube') diff --git a/youtube/subscriptions.py b/youtube/subscriptions.py index 3cb02ff..2c7b1fa 100644 --- a/youtube/subscriptions.py +++ b/youtube/subscriptions.py @@ -27,9 +27,10 @@ def open_database(): os.makedirs(settings.data_dir) connection = sqlite3.connect(database_path, check_same_thread=False) - # Create tables if they don't exist try: cursor = connection.cursor() + cursor.execute('''PRAGMA foreign_keys = 1''') + # Create tables if they don't exist cursor.execute('''CREATE TABLE IF NOT EXISTS subscribed_channels ( id integer PRIMARY KEY, yt_channel_id text UNIQUE NOT NULL, -- cgit v1.2.3