python bigquery

Solutions on MaxInterview for python bigquery by the best coders in the world

showing results for - "python bigquery"
Josué
18 Jan 2020
1from google.cloud import bigquery
2
3# Construct a BigQuery client object.
4client = bigquery.Client()
5
6query = """
7    SELECT name, SUM(number) as total_people
8    FROM `bigquery-public-data.usa_names.usa_1910_2013`
9    WHERE state = 'TX'
10    GROUP BY name, state
11    ORDER BY total_people DESC
12    LIMIT 20
13"""
14query_job = client.query(query)  # Make an API request.
15
16print("The query data:")
17for row in query_job:
18    # Row values can be accessed by field name or index.
19    print("name={}, count={}".format(row[0], row["total_people"]))