put improved foreign key constraints on DB to fix bug where when I delete a cset, that was being used to compare_to, it breaks

This commit is contained in:
2026-02-10 21:35:41 +11:00
parent e3d2d8ea08
commit 20239d72c8
3 changed files with 11 additions and 4 deletions

2
db.py
View File

@@ -8,6 +8,8 @@ def connect_db(as_object):
conn = sqlite3.connect('/data/finance.db')
else:
conn = sqlite3.connect('./finance.db')
# allow deleting cset to clear our compare_to properly in finance table
conn.execute("PRAGMA foreign_keys = ON;")
if as_object:
conn.row_factory = sqlite3.Row # This allows us to access columns by name
return conn