[英]Access BigQuery data from Jupyter Notebook in AI Platform Google Cloud
I am trying to get access to the data stored in BigQuery from Jupyter Notebook in AI Platform on Google cloud platform.我正在尝试从 Google 云平台上的 AI 平台中的 Jupyter Notebook 访问存储在 BigQuery 中的数据。 First, I tried the following code:
首先,我尝试了以下代码:
from google.cloud import bigquery
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(r'\local_path\gcpcred.json')
project_id = 'my-bq'
client = bigquery.Client(credentials= credentials,project=project_id)
The authentication credentials are stored in a json file named gcpcred on the local machine but this gives me an error saying身份验证凭据存储在本地计算机上名为 gcpcred 的 json 文件中,但这给了我一个错误提示
FileNotFoundError: [Errno 2] No such file or directory: '\local_path\gcpcred.json
FileNotFoundError:[Errno 2] 没有这样的文件或目录:'\local_path\gcpcred.json
I thought that since I am running this in AI Platform(on the cloud itself), I would not have to use this API and authenticate.我认为由于我在 AI Platform(在云本身上)运行它,我不必使用这个 API 并进行身份验证。
So I simply wrote:所以我简单地写道:
%%bigquery
SELECT * FROM `project.dataset.table` LIMIT 1000
I got an error saying我有一个错误说
ERROR: 403 Access Denied: User does not have access to the table错误:403 拒绝访问:用户无权访问该表
How do I access the table?如何访问该表? Please help
请帮忙
Seems like the service account assosiated with jupyter notebooks doesn't have enough privilage to access bigquery.似乎与 jupyter 笔记本关联的服务帐户没有足够的权限来访问 bigquery。 You can update it in IAM service Account section with required privilages.
您可以在 IAM 服务帐户部分使用所需的权限对其进行更新。 The links Bellow will provide further clarification:
下面的链接将提供进一步的说明:
Visualizing BigQuery data in a Jupyter notebook在 Jupyter 笔记本中可视化 BigQuery 数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.