diff --git a/database/src/database/sqlite_database.py b/database/src/database/sqlite_database.py index 68d868d..a70c4ff 100644 --- a/database/src/database/sqlite_database.py +++ b/database/src/database/sqlite_database.py @@ -14,6 +14,11 @@ def __init__(self, id: str, variant: str, ro: bool=True): file_name = f'{id}_{variant}' self.path = f'{Path(__file__).resolve().parents[2]}/db/{file_name}.db' self.exists = os.path.exists(self.path) + + # Create db directory if it doesn't exist and we're not in read-only mode + if not ro: + os.makedirs(os.path.dirname(self.path), exist_ok=True) + uri_path = self.path if ro: uri_path = f'file:{self.path}?immutable=1' @@ -93,4 +98,4 @@ def close(self): Updates the database with any changes made and closes it. ''' self.db.commit() - self.db.close() \ No newline at end of file + self.db.close()