Skip to content

Commit

Permalink
update api calls for sqlalchemy 2.0
Browse files Browse the repository at this point in the history
Signed-off-by: Erik Erlandson <[email protected]>
  • Loading branch information
erikerlandson committed Oct 21, 2023
1 parent f1e5a86 commit d1d2ed3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion osc_ingest_trino/trino_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def _do_sql(sql, engine, verbose=False):
sql = text(str(sql))
if verbose:
print(sql)
qres = engine.execute(sql)
with engine.begin() as cxn:
qres = cxn.execute(sql)
res = None
if qres.returns_rows:
res = qres.fetchall()
Expand Down
6 changes: 4 additions & 2 deletions osc_ingest_trino/unmanaged/unmanaged_hive_ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import uuid

import pandas as pd
from sqlalchemy import text

from osc_ingest_trino import create_table_schema_pairs, upload_directory_to_s3

Expand Down Expand Up @@ -29,8 +30,9 @@ def _prefix(pfx, schema, table):


def drop_unmanaged_table(catalog, schema, table, engine, bucket, prefix=_default_prefix, verbose=False):
sql = f"drop table if exists {catalog}.{schema}.{table}"
qres = engine.execute(sql)
sql = text(f"drop table if exists {catalog}.{schema}.{table}")
with engine.begin() as cxn:
qres = cxn.execute(sql)
dres = bucket.objects.filter(Prefix=f"{_prefix(prefix, schema, table)}/").delete()
if verbose:
print(dres)
Expand Down

0 comments on commit d1d2ed3

Please sign in to comment.