You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 16, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 16, 2026. It is now read-only.
Ability to Create Engine From an Existing BigQuery Client #464
In situations where a user already has a google.cloud.bigquery.Client object, it'd be helpful to be able to create an sqlalchemy engine either using that already existing BigQuery client object or the same credentials used by that client.
I'm poking around and one option would be something like
to create a client with the same credentials. This is unfortunately accessing a private _credentials attribute on the client. We might look to adding a public interface for this on the client so callers don't need to access _credentials.
The problem is that the engine will still try to create the client itself even if it will end up being replaced by the one from connnect_args. That attempt to create the client by the engine may fail (we're assuming the big query client is created by some machinery that's opaque to the user here.) I'm not seeing a clean way to avoid this.
Any other suggestions? I'm more than happy to work on this if it seems like a reasonable thing to support!
engine=sqlalchemy.engine.create_engine(
# do not let sqlalchemy_bigquery attempt to create a client itself'bigquery://project/?create_client=False',
# instead we supply one of our ownconnect_args={'client': bq_client},
)
?
More than happy to put together a pull request for this!
Activity
waltaskew commentedon Jul 20, 2022
What about something like:
?
More than happy to put together a pull request for this!