Kel
Kel

Reputation: 51

GBQexception: How to read data with big query that is stored on google drive spreadsheet

I uploaded a dataset to bigquery via the google drive option and linking the google spreadsheet to a dataset which I call 'dim_table'

I then created a query to pull data from that dim_table dataset that I run daily.

I am trying to create an automated script that will run the same query code I created to get the dim_table data set and create a new dataset call chart_A

When I run this simple code:

import pandas_gbq as gbq
gbq.read_gbq("Select * from data.dim_stats",'ProjectID')

I get an error:

GenericGBQException: Reason: 403 Access Denied: BigQuery BigQuery: No OAuth token with Google Drive scope was found.

I have been trying to read documentation on pandas gbq but could not find any documentation that points me on how I can authenticate gdrive with pandas gbq or use oauth. Any help is appreciated! :)

Let me know if you need me to comeup with a sample table online for testing.

best

Upvotes: 1

Views: 1142

Answers (1)

Yurci
Yurci

Reputation: 576

I haven't used pandas-gbq but authentication methods with BigQuery mentioned here [1].

  1. Create service account with a BigQuery role that can access to your datasets [2].
  2. Create and download the service account's JSON key [3].
  3. Set the private_key parameter to a file path to the JSON file or a string contains the JSON contents.

Also related guide to query Google Drive data without using pandas-gbq is here [4].

Upvotes: 1

Related Questions