summaryrefslogtreecommitdiff
path: root/db_sqlite.py
diff options
context:
space:
mode:
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