Skip to content

Instantly share code, notes, and snippets.

@antoniocachuan
Last active August 26, 2021 04:32
Show Gist options
  • Select an option

  • Save antoniocachuan/721aeba7d10822c521e9094fdf4d416e to your computer and use it in GitHub Desktop.

Select an option

Save antoniocachuan/721aeba7d10822c521e9094fdf4d416e to your computer and use it in GitHub Desktop.
Using Keyless API Google Cloud
#Read the full article on https://medium.com/@alipazaga07
import os
from google.cloud import bigquery
# Reference the SA
os.environ["GOOGLE_CLOUD_PROJECT"] ='datapath'. #The GCP project ID
os.environ["GOOGLE_APPLICATION_CREDENTIALS"] ='configoutput.json' #configuration file
# BigQuery client object.
client = bigquery.Client()
query = """
SELECT daily_confirmed_cases, daily_deaths, country_territory_code
FROM `bigquery-public-data.covid19_ecdc.covid_19_geographic_distribution_worldwide`
WHERE date = '2020–12–01'
ORDER BY daily_confirmed_cases DESC
"""
query_job = client.query(query) # API request.
print("Query result")
for row in query_job:
print(f"country={row['country_territory_code']}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment