Skip to content

Commit

Permalink
Merge pull request #1235 from SpiNNakerManchester/db_cleanup
Browse files Browse the repository at this point in the history
only run ddl if a new file
  • Loading branch information
rowleya authored Nov 13, 2024
2 parents 84e4b19 + b938954 commit 3d68315
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion spinn_front_end_common/utilities/sqlite_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,12 @@ def __init__(
# https://stackoverflow.com/a/21794758/301832
self.__db = sqlite3.connect(
f"{db_uri}?mode=ro", uri=True, timeout=timeout)
# can not run a DDL file
ddl_file = None
else:
if os.path.exists(database_file):
# No need to run the DDL file again
ddl_file = None
self.__db = sqlite3.connect(database_file, timeout=timeout)

# We want to assume control over transactions ourselves
Expand All @@ -131,7 +136,7 @@ def __init__(
if text_factory is not None:
self.__db.text_factory = text_factory

if not read_only and ddl_file:
if ddl_file:
with open(ddl_file, encoding="utf-8") as f:
sql = f.read()
self.__db.executescript(sql)
Expand Down

0 comments on commit 3d68315

Please sign in to comment.