aboutsummaryrefslogtreecommitdiff
path: root/src/db/init.py
diff options
context:
space:
mode:
authorJoris2020-05-31 17:39:28 +0200
committerJoris2020-05-31 17:39:28 +0200
commit1bed85a9b107d1b03e71b848829cb7b1f33060f4 (patch)
tree7e9bc7dd0813b9426e293dde7913717746a479f8 /src/db/init.py
parenta585e507cbe2c05cc846013cafe433953e514295 (diff)
downloadtodo-1bed85a9b107d1b03e71b848829cb7b1f33060f4.tar.gz
todo-1bed85a9b107d1b03e71b848829cb7b1f33060f4.tar.bz2
todo-1bed85a9b107d1b03e71b848829cb7b1f33060f4.zip
Prevent removing a tag being used
Diffstat (limited to 'src/db/init.py')
-rw-r--r--src/db/init.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/db/init.py b/src/db/init.py
index 6b4cbea..77920cf 100644
--- a/src/db/init.py
+++ b/src/db/init.py
@@ -8,9 +8,9 @@ def init(path):
database = sqlite3.connect(path)
- if is_db_new:
+ cursor = database.cursor()
- cursor = database.cursor()
+ if is_db_new:
cursor.execute(
" CREATE TABLE IF NOT EXISTS tasks("
@@ -43,6 +43,8 @@ def init(path):
" PRIMARY KEY (task_id, tag_id)"
" )")
- database.commit()
+ cursor.execute("PRAGMA foreign_keys = ON")
+
+ database.commit()
return database