Class Connection (3.25.0)

Connection(client=None, bqstorage_client=None, prefer_bqstorage_client=True)

DB-API Connection to Google BigQuery.

Parameters

Name Description
client Optional[google.cloud.bigquery.Client]

A REST API client used to connect to BigQuery. If not passed, a client is created using default options inferred from the environment.

bqstorage_client Optional[google.cloud.bigquery_storage_v1.BigQueryReadClient]

A client that uses the faster BigQuery Storage API to fetch rows from BigQuery. If not passed, it is created using the same credentials as client (provided that BigQuery Storage dependencies are installed).

prefer_bqstorage_client Optional[bool]

Prefer the BigQuery Storage client over the REST client. If Storage client isn't available, fall back to the REST client. Defaults to True.

Methods

close

close()

Close the connection and any cursors created from it.

Any BigQuery clients explicitly passed to the constructor are not closed, only those created by the connection instance itself.

commit

commit()

No-op, but for consistency raise an error if connection is closed.

cursor

cursor()

Return a new cursor object.

Returns
Type Description
google.cloud.bigquery.dbapi.Cursor A DB-API cursor that uses this connection.