Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EBAS reader: open db in read only mode only #1233

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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