Cormac
03/04/2024, 2:54 PMquery = f"SELECT * FROM `{table}`"
print(f"Starting DB fetch")
with conn_obj.get_engine().connect() as connection:
print(f"Got DB connection")
with connection.execution_options(yield_per=yield_per).execute(query) as result:
print("Ran DB Query")
print(f"sending block partition")
time.sleep(1)
for block in result:
p_in.send(block)
...
fails with error
AttributeError: __enter__
This type of error suggests that context manager is not supported - but it it is if SQLAlchemy is version 2.
But my pip freeze
reports prefect-sqlalchemy==0.3.2
Can someone please assist?
1. What version of SQLAlchemy is prefect-sqlalchemy built over?
2. How do I do server-side cursors with Prefect SQLAlchemy?Nate
03/04/2024, 3:36 PMCormac
03/04/2024, 3:47 PMNate
03/04/2024, 3:52 PMprefect-sqlalchemy
is implemented to be async
if you want/need sync behavior, I might recommend:
• using sqlalchemy
directly
• contributing a sync interface to prefect-sqlalchemy
Cormac
03/04/2024, 3:53 PMCormac
03/04/2024, 4:13 PMNate
03/04/2024, 4:20 PMNate
03/04/2024, 4:21 PM@sync_compatible
to write an async function that you can use as if it were a sync function
like this oneNate
03/04/2024, 4:22 PM@sync_compatible
decorated function will behave like an async function in an async context (like an async
fn definition, or anywhere with a running event loop) but will behave sync otherwise (no need to await)Cormac
03/04/2024, 8:58 PMNate
03/04/2024, 9:03 PM