allow the db to persist in /srv/docker/container, if we are in PROD

This commit is contained in:
2025-04-29 15:15:37 +10:00
parent 1878b3c2f3
commit 3828f849a4

6
db.py
View File

@@ -1,9 +1,13 @@
# db.py
import sqlite3
import pprint
import os
def connect_db(as_object):
conn = sqlite3.connect('finance.db')
if 'ENV' in os.environ and os.environ['ENV'] == "production":
conn = sqlite3.connect('/finance.db')
else:
conn = sqlite3.connect('./finance.db')
if as_object:
conn.row_factory = sqlite3.Row # This allows us to access columns by name
return conn