summaryrefslogtreecommitdiff
path: root/db_sqlite.py
diff options
context:
space:
mode:
authorLouie S <louie@example.com>2023-09-16 09:36:14 -0400
committerLouie S <louie@example.com>2023-09-16 09:36:14 -0400
commit4292f8cf349f872fdd1d7065fbe159f43a7939a0 (patch)
tree68ae921b6d5b805c8d80eccc60c5195ef24b925d /db_sqlite.py
parent0f71101423a793fcdb78d500da6070c2a49374cf (diff)
Basic config file creation and loading working
Diffstat (limited to 'db_sqlite.py')
-rw-r--r--db_sqlite.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/db_sqlite.py b/db_sqlite.py
index 60c8aa0..7fe2745 100644
--- a/db_sqlite.py
+++ b/db_sqlite.py
@@ -23,6 +23,14 @@ def createTables():
database = QSqlDatabase.addDatabase("QSQLITE") # SQlite version 3
database.setDatabaseName(Globals.db_path)
+ # Create database parent directory if necessary
+ if not os.path.exists(os.path.dirname(Globals.db_path)):
+ try:
+ os.mkdir(os.path.dirname(Globals.db_path))
+ except:
+ print("Unable to open data source file.")
+ sys.exit(1)
+
if not database.open():
print("Unable to open data source file.")
sys.exit(1) # Error out. TODO consider throwing a dialog instead