Skip to main content

Python Client for Google BigQuery

GA pypi versions

Querying massive datasets can be time consuming and expensive without the right hardware and infrastructure. Google BigQuery solves this problem by enabling super-fast, SQL queries against append-mostly tables, using the processing power of Google’s infrastructure.

Quick Start

In order to use this library, you first need to go through the following steps:

  1. Select or create a Cloud Platform project.

  2. Enable billing for your project.

  3. Enable the Google Cloud BigQuery API.

  4. Setup Authentication.

Installation

Install this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions.

With virtualenv, it’s possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.

Supported Python Versions

Python >= 3.10

Unsupported Python Versions

Python <= 3.9.

The last version of this library compatible with Python 2.7 and 3.5 is google-cloud-bigquery==1.28.0.

Mac/Linux

pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-bigquery

Windows

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-bigquery

Example Usage

Perform a query

from google.cloud import bigquery

client = bigquery.Client()

# Perform a query.
QUERY = (
    'SELECT name FROM `bigquery-public-data.usa_names.usa_1910_2013` '
    'WHERE state = "TX" '
    'LIMIT 100')
query_job = client.query(QUERY)  # API request
rows = query_job.result()  # Waits for query to finish

for row in rows:
    print(row.name)

Instrumenting With OpenTelemetry

This application uses OpenTelemetry to output tracing data from API calls to BigQuery. To enable OpenTelemetry tracing in the BigQuery client the following PyPI packages need to be installed:

pip install google-cloud-bigquery[opentelemetry] opentelemetry-exporter-gcp-trace

After installation, OpenTelemetry can be used in the BigQuery client and in BigQuery jobs. First, however, an exporter must be specified for where the trace data will be outputted to. An example of this can be found here:

from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor
from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
tracer_provider = TracerProvider()
tracer_provider = BatchSpanProcessor(CloudTraceSpanExporter())
trace.set_tracer_provider(TracerProvider())

In this example all tracing data will be published to the Google Cloud Trace console. For more information on OpenTelemetry, please consult the OpenTelemetry documentation.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

google_cloud_bigquery-3.45.1.tar.gz (528.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

google_cloud_bigquery-3.45.1-py3-none-any.whl (267.7 kB view details)

Uploaded Python 3

File details

Details for the file google_cloud_bigquery-3.45.1.tar.gz.

File metadata

  • Download URL: google_cloud_bigquery-3.45.1.tar.gz
  • Upload date:
  • Size: 528.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.11.2

File hashes

Hashes for google_cloud_bigquery-3.45.1.tar.gz
Algorithm Hash digest
SHA256 f89bb9d1d546b7495a4c3baaea4f2d56c336a4e06581a19acd8eb8547266e591
MD5 8e75de9d5592e4e745b9e661a098473b
BLAKE2b-256 60f6e12217ae9518d35e014b2302ddd3a7e047c0854c692e536395c12eb4f81c

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_cloud_bigquery-3.45.1.tar.gz:

Publisher: google-cloud-sdk-py@oss-exit-gate-prod.iam.gserviceaccount.com

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
  • Statement: Publication detail:
    • Token Issuer: https://accounts.google.com
    • Service Account: google-cloud-sdk-py@oss-exit-gate-prod.iam.gserviceaccount.com

File details

Details for the file google_cloud_bigquery-3.45.1-py3-none-any.whl.

File metadata

File hashes

Hashes for google_cloud_bigquery-3.45.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d58c1b77b7c5ae1a405be7c5341e78ebf61f352173393cf35ef722c1432e6a73
MD5 bf71b8148f49aedb703d289c2acd9e26
BLAKE2b-256 5cce89915c377eaffca9d509e64631185254fa8e07f0fedd3fb749a31f9f7915

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_cloud_bigquery-3.45.1-py3-none-any.whl:

Publisher: google-cloud-sdk-py@oss-exit-gate-prod.iam.gserviceaccount.com

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.
  • Statement: Publication detail:
    • Token Issuer: https://accounts.google.com
    • Service Account: google-cloud-sdk-py@oss-exit-gate-prod.iam.gserviceaccount.com

Release history Release notifications | RSS feed

This release

3.45.1 This release

2 files

3.45.0

2 files

3.44.0

2 files

3.43.0

2 files

3.42.3

2 files

3.42.2

2 files

3.42.1

2 files

3.42.0

2 files

3.41.0

2 files

3.40.1

2 files

3.40.0

2 files

3.39.0

2 files

3.38.0

2 files

3.37.0

2 files

3.36.0

2 files

3.35.1

2 files

3.35.0

2 files

3.34.0

2 files

3.33.0

2 files

3.32.0

2 files

3.31.0

2 files

3.30.0

2 files

3.29.0

2 files

3.28.0

2 files

3.27.0

2 files

3.26.0

2 files

3.25.0

2 files

3.24.0

2 files

3.23.1

2 files

3.23.0

2 files

3.22.0

2 files

3.21.0

2 files

3.20.1

2 files

3.20.0

2 files

3.19.0

2 files

3.18.0

2 files

3.17.2

2 files

3.17.1

2 files

3.17.0

2 files

3.16.0

2 files

3.15.0

2 files

3.14.1

2 files

3.14.0

2 files

3.13.0

2 files

3.12.0

2 files

3.11.4

2 files

3.11.3

2 files

3.11.2

2 files

3.11.1

2 files

3.11.0

2 files

3.10.0

2 files

3.9.0

2 files

3.8.0

2 files

3.7.0

2 files

3.6.0

2 files

3.5.0

2 files

3.4.2

2 files

3.4.1

2 files

3.4.0

2 files

3.3.6

2 files

3.3.5

2 files

3.3.3

2 files

3.3.2

2 files

3.3.1

2 files

3.3.0

2 files

3.2.0

2 files

3.1.0

2 files

3.0.1

2 files

3.0.0

2 files

2.34.4

2 files

2.34.3

2 files

2.34.2

2 files

2.34.1

2 files

2.34.0

2 files

2.33.0

2 files

2.32.0

2 files

2.31.0

2 files

2.30.1

2 files

2.30.0

2 files

2.29.0

2 files

2.28.1

2 files

2.28.0

2 files

2.27.1

2 files

2.27.0

2 files

2.26.0

2 files

2.25.2

2 files

2.25.1

2 files

2.25.0

2 files

2.24.1

2 files

2.24.0

2 files

2.23.3

2 files

2.23.2

2 files

2.23.1

2 files

2.23.0

2 files

2.22.1

2 files

2.22.0

2 files

2.21.0

2 files

2.20.0

2 files

2.19.0

2 files

2.18.0

2 files

2.17.0

2 files

2.16.1

2 files

2.16.0

2 files

2.15.0

2 files

2.14.0

2 files

2.13.1

2 files

2.13.0

2 files

2.12.0

2 files

2.11.0

2 files

2.10.0

2 files

2.9.0

2 files

2.8.0

2 files

2.7.0

2 files

2.6.2

2 files

2.6.1

2 files

2.6.0

2 files

2.5.0

2 files

2.4.0

2 files

2.3.1

2 files

2.2.0

2 files

2.1.0

2 files

2.0.0

2 files

1.28.3

2 files

1.28.2

2 files

1.28.1

2 files

1.28.0

2 files

1.27.2

2 files

1.26.1

2 files

1.26.0

2 files

1.25.0

2 files

1.24.0

2 files

1.23.1

2 files

1.23.0

2 files

1.22.0

2 files

1.21.0

2 files

1.20.0

2 files

1.19.1

2 files

1.19.0

2 files

1.18.1

2 files

1.18.0

2 files

1.17.1

2 files

1.17.0

2 files

1.16.1

2 files

1.16.0

2 files

1.15.1

2 files

1.15.0

2 files

1.14.1

2 files

1.14.0

2 files

1.13.1

2 files

1.13.0

2 files

1.12.2

2 files

1.12.1

2 files

1.12.0

2 files

1.11.4

2 files

1.11.3

2 files

1.11.2

2 files

1.11.1

2 files

1.10.1

2 files

1.10.0

2 files

1.9.1

2 files

1.9.0

2 files

1.8.2

2 files

1.8.1

2 files

1.8.0

2 files

1.7.2

2 files

1.7.0

2 files

1.6.2

2 files

1.6.1

2 files

1.6.0

2 files

1.5.2

2 files

1.5.1

2 files

1.5.0

2 files

1.4.0

2 files

1.3.0

2 files

1.2.0

2 files

1.1.0

2 files

1.0.0

2 files

0.32.0

2 files

0.31.0

2 files

0.30.0

2 files

0.29.0

2 files

0.28.0

2 files

0.27.0

2 files

0.26.0

2 files

0.25.0

2 files

0.24.0

2 files

0.23.0

2 files

0.22.1

2 files

0.22.0

2 files

0.21.0

2 files

0.20.0

2 files

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page