I would like to run SQL queries to BigQuery using Python, I am a complete beginner at this. I have read the 'Create A Simple Application With the API' page (https://cloud.google.com/bigquery/create-simple-app-api#bigquery-simple-app-build-service-python) and have got my code as follows:
from google.cloud import bigquery
client = bigquery.Client()
query_job = client.query("""
#standardSQL
SELECT date, totals.visits AS visits
FROM `myproject.mydataset.ga_sessions_20180111`
GROUP BY date
""")
results = query_job.result() # Waits for job to complete.
for row in results:
print("{}: {}".format(row.title, row.unique_words))
When I run this I get the error: OSError: Project was not passed and could not be determined from the environment.
Reading up on this I think the issue relates to the authentication of client = bigquery.Client() - can somebody explain to me in simple terms how this works? Does it look for my authentication details if I am already logged in? If I have permission for multiple projects do I need to specify which one I am working with?