Hello, I am trying to use server-side cursors wit...
# data-tricks-and-tips
c
Hello, I am trying to use server-side cursors with prefect-sqlalchemy and am unable to get it to work. Code fragment:
Copy code
query = 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
Copy code
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?
n
please avoid spamming channels with the same question please - I've answered in a different channel
c
@Nate thanks for responding. I am spanning multiple channels because my previous 2 messages on other issues in January were ignored. So I was unsure where to raise questions.
n
#CL09KU1K7 is a solid choice, we do our best to address questions as possible given the bandwidth we have