简体   繁体   English

从 AI Platform Google Cloud 中的 Jupyter Notebook 访问 BigQuery 数据

[英]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 数据

Getting started with authentication身份验证入门

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 python dataframe 从 Google AI Platform Notebook 导出到 Google BigQuery 中的表 - Export a python dataframe from Google AI Platform Notebook to a table in Google BigQuery 从本地Jupyter笔记本中访问Google BigQuery数据 - Access Google BigQuery Data from local Jupyter Notebooks 如何将 Google Cloud Platform (BigQuery/Cloud SQL) 中的数据导入 R? - How to import data from Google Cloud Platform (BigQuery/Cloud SQL) into R? 无法将 BigQuery 数据导入 GCP AI Notebook - Unable to import BigQuery data into GCP AI Notebook BigQuery-授予对其他Google Cloud Platform项目的访问权限 - BigQuery - Grant Access to Other Google Cloud Platform Projects 将数据从 bigquery 导出到 Jupyter notebook 需要很长时间 - Takes too long to export data from bigquery into Jupyter notebook VCP Google Cloud Platform 的 Dataflow Pub/Sub 主题到 BigQuery 未从订阅中提取数据 - VCP Google Cloud Platform's Dataflow Pub/Sub Topic to BigQuery not Pulling data from subscription Google BigQuery,如何将数据从Google云存储加载到BigQuery - Google BigQuery, How to load data from google cloud storage to BigQuery 将数据从谷歌云存储加载到 BigQuery - Loading data from google cloud storage to BigQuery 从Google Cloud BigQuery读取数据 - Reading data from Google Cloud BigQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM