Last active
August 26, 2021 04:32
-
-
Save antoniocachuan/721aeba7d10822c521e9094fdf4d416e to your computer and use it in GitHub Desktop.
Using Keyless API Google Cloud
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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