Skip to content

Commit

Permalink
update db.execute wrapper for new sqlalchemy behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrammer committed Jan 22, 2024
1 parent 535a16a commit c6161f1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions grizli/aws/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ def SQL(query_text, engine=None, pd_kwargs={}, **kwargs):

def execute(sql_text):
"""
Wrapper around engine.execute()
Wrapper around `sqlalchemy.engine.Engine.execute()`
"""
global _ENGINE

Expand All @@ -1838,7 +1838,14 @@ def execute(sql_text):
else:
refresh_engine()

resp = _ENGINE.execute(sql_text)
if hasattr(_ENGINE, 'execute'):
resp = _ENGINE.execute(sql_text)
else:
conn = _ENGINE.connect()
resp = conn.exec_driver_sql(sql_text)
conn.commit()
conn.close()

return resp


Expand Down

0 comments on commit c6161f1

Please sign in to comment.