-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to get QueryExecutionId from cursor when using sqlalchemy + pyathena #339
Comments
The |
Are query_id and cancel methods available with PyAthenaJDBC ? |
No, it is not available; the JDBC version is also not asynchronous in query execution. |
Does that mean, with PyAthena + SQL Alchemy, when a cursor is executing a query, the same cursor cannot be used to call cursor.query_id? |
You can easily get the query ID from the cursor if you execute the query in a separate thread. |
Following up on this @laughingman7743. Quick context. I have a FastAPI application that facilitates data from RDS and Athena backends using asynchronous calls. Currently to do this async for Athena I use Before spending time investigating further is an async dialect for SQL Alchemy completely impossible? If so is this from a design choice from PyAthena, a limitation within SQL Alchemy, a blocker from Athena, or some combination of the three? |
AsyncCursor is a cursor that I created with a self-defined interface, not the interface as summarized in PEP 249, which makes it difficult to use SQLAlchemy. I believe SQLAlchemy only supports the DB-API of the PEP249 specification. |
Hi! Running into a similar usecase, the SQLAlchemy interface has fantastic ergonomics but I'm having trouble parallelizing multiple requests to cut down on response time. Is it possible to grab the underlying query built up using SQLAlchemy and then use AsyncCursor to execute it instead? Or would that not even help since execution blocks? |
I am using sqlalchemy + pyathena
Here is an example code:
from urllib.parse import quote_plus
from sqlalchemy import create_engine, inspect
conn_str = "awsathena+rest://@athena.{region_name}.amazonaws.com:443/{schema_name}?s3_staging_dir={s3_staging_dir}"
engine = create_engine(conn_str.format(region_name="us-east-1", schema_name="default", s3_staging_dir=quote_plus("s3://aws-athena-query-results-bucket/")))
conn = engine.raw_connection()
cursor = conn.cursor()
cursor.execute("""SELECT * FROM "database"."table""")
for sqlalchemy + pyathena setup, I want to know if there is a way to get QueryExecutionId of a running query from its cursor so that it can be later used to cancel the query using cancel method.
The text was updated successfully, but these errors were encountered: