google-cloud-python icon indicating copy to clipboard operation
google-cloud-python copied to clipboard

Is async support available?

Open eshwen opened this issue 2 years ago • 3 comments

Issue

I have a large codebase with several intensive queries to BigQuery. I'm trying to port these synchronous queries to async to improve performance, but am unable to create an async SQLAlchemy engine. Is there a specific dialect and/or driver I can provide in order to enable async functionality? Or is there an easy workaround?

MWE

A simple script:

from sqlalchemy.ext.asyncio import create_async_engine

conn_path = "bigquery://"
engine = create_async_engine(conn_path)

Resulting in the traceback

Traceback (most recent call last):
  File "/Users/eshwen.bhal/Library/Application Support/JetBrains/PyCharm2024.1/scratches/scratch_6.py", line 4, in <module>
    engine = create_async_engine(conn_path)
  File "/Users/eshwen.bhal/Documents/GitHub/mjolnir/.venv/lib/python3.11/site-packages/sqlalchemy/ext/asyncio/engine.py", line 118, in create_async_engine
    return AsyncEngine(sync_engine)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/eshwen.bhal/Documents/GitHub/mjolnir/.venv/lib/python3.11/site-packages/sqlalchemy/ext/asyncio/engine.py", line 1023, in __init__
    raise exc.InvalidRequestError(
sqlalchemy.exc.InvalidRequestError: The asyncio extension requires an async driver to be used. The loaded 'bigquery' is not async.

Environment

  • Python: 3.11.8
  • SQLAlchemy: 2.0.28
  • sqlalchemy-bigquery: 1.11.0
  • Chip: Apple M2 Pro
  • OS: macOS 14.4.1

eshwen avatar May 02 '24 13:05 eshwen

Thank you for raising this issue. This feature will be dependent on async support in googleapis/python-bigquery. Please see https://github.com/googleapis/google-cloud-python/issues/15742 for future updates.

Linchin avatar Jun 05 '24 22:06 Linchin

This issue was moved from the following repo as part of the monorepo migration: googleapis/python-bigquery-sqlalchemy

chalmerlowe avatar Mar 02 '26 14:03 chalmerlowe

This issue is being bulk closed due to inactivity. Please re-open if you think this still requires attention, and we'll take another look. Thanks!

daniel-sanche avatar May 28 '26 01:05 daniel-sanche