Skip to content

Commit 43a7aa3

Browse files
committed
Open GTN SQLite connection read-only with autocommit isolation
The search module only ever reads from the database, so opening with mode=ro and isolation_level=None prevents accidental writes and skips SQLite's implicit BEGIN transactions. Addresses PR review feedback from @bgruening.
1 parent 2a4d229 commit 43a7aa3

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

lib/galaxy/agents/gtn/search.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,13 @@ def _download_database(self):
167167
raise FileNotFoundError(f"GTN database not found at {self.db_path} and download failed: {e}") from e
168168

169169
def _get_connection(self) -> sqlite3.Connection:
170-
"""Get a database connection."""
171-
conn = sqlite3.connect(str(self.db_path))
170+
"""Open a read-only, autocommit connection to the GTN database."""
171+
conn = sqlite3.connect(
172+
f"file:{self.db_path}?mode=ro",
173+
uri=True,
174+
isolation_level=None,
175+
check_same_thread=False,
176+
)
172177
conn.row_factory = sqlite3.Row
173178
return conn
174179

0 commit comments

Comments
 (0)