Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Ability to Create Engine From an Existing BigQuery Client #464

Copy link
Copy link
Closed
@waltaskew

Description

@waltaskew
Issue body actions

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

bq_client: bigquery.Client
engine = sqlalchemy.engine.create_engine(
    'bigquery://project/?credentials_user_info_json=%s' % bq_client._credentials.to_json())

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.

I was also looking at something like

bq_client: bigquery.Client
engine = sqlalchemy.engine.create_engine(
  'bigquery://project', connect_args={'client': bq_client})

using the connect_args kwarg

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: bigqueryIssues related to the googleapis/python-bigquery-sqlalchemy API.Issues related to the googleapis/python-bigquery-sqlalchemy API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.