Skip to content

Commit

Permalink
Merge pull request #1233 from metno/1232-ebas-reader-open-sqlite3-db-…
Browse files Browse the repository at this point in the history
…in-read-only-mode-only

EBAS reader: open db in read only mode only
  • Loading branch information
lewisblake authored Jun 28, 2024
2 parents 2f4610a + f453e71 commit 383a2ee
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pyaerocom/io/ebas_file_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def get_table_names(self):
def get_table_columns(self, table_name):
"""Get all columns of a table in SQLite database file"""
req = f"select * from {table_name} where 1=0;"
with sqlite3.connect(self.database) as con:
with sqlite3.connect(f"file:{self.database}?mode=ro", uri=True) as con:
cur = con.cursor()
cur.execute(req)
return [f[0] for f in cur.description]
Expand Down Expand Up @@ -320,7 +320,7 @@ def execute_request(self, request, file_request=False):
raise ValueError(f"Unsupported request type {type(request)}")

try:
with sqlite3.connect(self.database) as con:
with sqlite3.connect(f"file:{self.database}?mode=ro", uri=True) as con:
cur = con.cursor()
cur.execute(sql_str)
return [f for f in cur.fetchall()]
Expand Down

0 comments on commit 383a2ee

Please sign in to comment.