Skip to main content

How to query a BigQuery table from Python

  1. Install the SDK:
pyproject.toml
dependencies = [
	"google-cloud-bigquery[bqstorage, pandas]",
]
  1. Create a BigQuery client:
client.py
from google.cloud import bigquery
 
bq_client = bigquery.Client(project="project")
  1. Execute your query and store the result:
query.py
query = """
SELECT column_one, column_two
FROM bq_table
WHERE column_three = true
"""
 
df = bq_client.query(query).to_dataframe()