Skip to content Skip to sidebar Skip to footer

Cannot Query Tables From Sheets In Bigquery

I am trying to use BigQuery inside python to query a table that is generated via a sheet: from google.cloud import bigquery # Prepare connexion and query bigquery_client = bigquer

Solution 1:

You are missing the scopes for the credentials. I'm pasting the code snippet from the official documentation.

In addition, do not forget to give at least VIEWER access to the Service Account in the Google sheet.

from google.cloud import bigquery
import google.auth

# Create credentials with Drive & BigQuery API scopes.# Both APIs must be enabled for your project before running this code.
credentials, project = google.auth.default(
    scopes=[
        "https://www.googleapis.com/auth/drive",
        "https://www.googleapis.com/auth/bigquery",
    ]
)

# Construct a BigQuery client object.
client = bigquery.Client(credentials=credentials, project=project)

Post a Comment for "Cannot Query Tables From Sheets In Bigquery"