We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c0a1951 commit ec4d536Copy full SHA for ec4d536
1 file changed
api/app/api/utils.py
@@ -166,10 +166,13 @@ def execute_sql(sql_query: str):
166
raise NotReadOnlyException("Only read-only queries are allowed.")
167
168
with engine.connect() as connection:
169
- sql_text = text(sql_query)
170
-
171
- # result = connection.execute(sql_text, {'param': 'value'})
172
- result = connection.execute(sql_text)
+ connection = connection.execution_options(
+ postgresql_readonly=True
+ )
+ with connection.begin():
173
+ sql_text = text(sql_query)
174
+ # result = connection.execute(sql_text, {'param': 'value'})
175
+ result = connection.execute(sql_text)
176
177
column_names = list(result.keys())
178
if 'state' not in column_names and any(c in column_names for c in ['city', 'county']):
0 commit comments