aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-01-18 11:47:04 +0300
committerFrederick Muriuki Muriithi2023-01-18 11:52:35 +0300
commit0f0b7f875cf88c85ee35caf24793ffbefe9f0906 (patch)
tree02dfde0fc5f75312a23c1a9a3fada5202a9f3ef8
parentb6ff005d4040b1a70230df42a91a0cbee42c3031 (diff)
downloadgenenetwork3-0f0b7f875cf88c85ee35caf24793ffbefe9f0906.tar.gz
auth: Enable FOREIGN KEY constraint for the connections
Enable the FOREIGN KEY constraints for the connections to the database to help with queries that would otherwise lead to data corruption.
-rw-r--r--gn3/auth/db.py1
1 files changed, 1 insertions, 0 deletions
diff --git a/gn3/auth/db.py b/gn3/auth/db.py
index 256940d..b74f341 100644
--- a/gn3/auth/db.py
+++ b/gn3/auth/db.py
@@ -51,6 +51,7 @@ def connection(db_path: str, row_factory: Callable = sqlite3.Row) -> Iterator[Db
"""Create the connection to the auth database."""
conn = sqlite3.connect(db_path)
conn.row_factory = row_factory
+ conn.execute("PRAGMA foreign_keys = ON")
try:
yield conn
except sqlite3.Error as exc: