Class Cursor (3.18.0)

Cursor(connection)

DB-API Cursor to Google BigQuery.

Parameter

NameDescription
connectiongoogle.cloud.bigquery.dbapi.Connection

A DB-API connection to Google BigQuery.

Properties

query_job

google.cloud.bigquery.job.query.QueryJob | None: The query jobcreated by the lastexecute() call, if a query job was created.

Note:If the lastexecute() call wasexecutemany(), this is thelast job created byexecutemany().

Methods

close

execute

Prepare and execute a database operation.

Note:When setting query parameters, values which are "text"(unicode in Python2,str in Python3) will usethe 'STRING' BigQuery type. Values which are "bytes" (str inPython2,bytes in Python3), will use using the 'BYTES' type. Adatetime.datetime parameter without timezone information uses the 'DATETIME' BigQuery type (example: Global Pi Day Celebration March 14, 2017 at 1:59pm). Adatetime.datetime parameter with timezone information uses the 'TIMESTAMP' BigQuery type (example: a wedding on April 29, 2011 at 11am, British Summer Time).

For more information about BigQuery data types, see:https://cloud.google.com/bigquery/docs/reference/standard-sql/data-types`STRUCT`/`RECORD` and `REPEATED` query parameters are notyet supported. See:https://github.com/GoogleCloudPlatform/google-cloud-python/issues/3524
Parameters
NameDescription
operationstr

A Google BigQuery query string.

parametersUnion[Mapping[str, Any], Sequence[Any]]

(Optional) dictionary or sequence of parameter values.

job_idstr None

(Optional and discouraged) The job ID to use when creating the query job. For best performance and reliability, manually setting a job ID is discouraged.

job_configgoogle.cloud.bigquery.job.QueryJobConfig

(Optional) Extra configuration options for the query job.

executemany

Parameters
NameDescription
operationstr

A Google BigQuery query string.

seq_of_parametersUnion[Sequence[Mapping[str, Any], Sequence[Any]]]

Sequence of many sets of parameter values.

fetchall

Exceptions
TypeDescription
google.cloud.bigquery.dbapi.InterfaceErrorif called beforeexecute().
Returns
TypeDescription
List[Tuple]A list of all the rows in the results.

fetchmany

Parameter
NameDescription
sizeint

(Optional) Maximum number of rows to return. Defaults to thearraysize property value. Ifarraysize is not set, it defaults to1.

Exceptions
TypeDescription
google.cloud.bigquery.dbapi.InterfaceErrorif called beforeexecute().
Returns
TypeDescription
List[Tuple]A list of rows.

fetchone

Exceptions
TypeDescription
google.cloud.bigquery.dbapi.InterfaceErrorif called beforeexecute().
Returns
TypeDescription
TupleA tuple representing a row orNone if no more data is available.

setinputsizes

setoutputsize

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-16 UTC.