Run a deterministic GoogleSQL query
Run a deterministic SQL query; BigQuery provides tabular results for analytical application workflows.
Configure the REST endpoint and anonymous credentials, then query a hello-world message.
SDK dependencies
Run in a new example directory
python3 -m venv .venv
source .venv/bin/activate
python -m pip install google-cloud-bigquery Save as hello.py
import os
from google.auth.credentials import AnonymousCredentials
from google.cloud import bigquery
client = bigquery.Client(
project=os.environ['GOOGLE_CLOUD_PROJECT'],
credentials=AnonymousCredentials(),
client_options={"api_endpoint": os.environ["BIGQUERY_EMULATOR_HOST"]},
)
rows = list(client.query("SELECT 'Hello from LocalCloud!' AS message").result(timeout=30))
assert rows[0].message == 'Hello from LocalCloud!'
print(rows[0].message)
client.close() Run the example
python hello.py Verify the result
The command completes successfully and prints the expected output shown below.
Expected output
Hello from LocalCloud!