18 August 2018 · npac ·       Add to Favorites   Report

How to run a BigQuery SQL in Python

How to execute a BigQuery SQL Query using Python. How would I change this/ what do I have to add for it to run in Python?

First of all, You need to use the BigQuery Python client lib, then something like the below sample code should get you up and running:

from google.cloud import bigquery
client = bigquery.Client(project='PROJECT_ID')
query = "SELECT...."
dataset = client.dataset('dataset')
table = dataset.table(name='table')
job = client.run_async_query('my-job', query)
job.destination = table
job.write_disposition= 'WRITE_TRUNCATE'


posted on 18 August 2018

Read great educational content like this and a lot more !

Members get free exclusive access to content, new courses, and discounts. Signup for a free account to write a post / comment / upvote posts. Creating an account takes less than 5 seconds and you can start earning badges & points too