Emre KABALCI
Emre KABALCI

Reputation: 31

Calling external table from bigquery with python

While I trying to reach the external table's data, I'm getting error like as below. I can not solve this issue. Here are the details about the situation;

google.api_core.exceptions.NotFound: 404 Not found: Files /gdrive/id/id123456id

PS: id123456id is a dummy id.

The file with ID id123456 id exists in my Google Drive. Bigquery table looking this id.

bq_test.json -> service account credential's JSON file. This service account has those roles;

Here is my code block:

from google.cloud import bigquery
from google.oauth2.service_account import Credentials

scopes = (
        'https://www.googleapis.com/auth/bigquery',
        'https://www.googleapis.com/auth/cloud-platform',
        'https://www.googleapis.com/auth/drive'
)
credentials = Credentials.from_service_account_file('bq_test.json')
credentials = credentials.with_scopes(scopes)
client = bigquery.Client(credentials=credentials)

QUERY = (
        """SELECT * FROM
            `project_name.dataset_name.ext_table`
            LIMIT 5"""
        )
query_job = client.query(QUERY)
rows = query_job.result()

for row in rows:
    print(row.name)

Upvotes: 1

Views: 841

Answers (1)

Emre KABALCI
Emre KABALCI

Reputation: 31

I solved the problem as follows;

This flow provides the solution in my case.

Upvotes: 1

Related Questions