简体   繁体   English

我不能在datalab中查询bigquery表吗?

[英]I can not consult bigquery table in datalab?

I'm working on datalab but when I try to query a table in bigquery I get the following error: 我正在使用datalab,但是当我尝试在bigquery中查询表时,出现以下错误:

Exception: invalid: Error while reading table: .... error message: Failed to read the spreadsheet. 异常:无效:读取表时出错:....错误消息:无法读取电子表格。 Errors: No OAuth token with Google Drive scope was found. 错误:未找到具有Google云端硬盘范围的OAuth令牌。

This only happens with the tables that are linked with google drive sheet. 这仅发生在与Google驱动器表链接的表上。

now enable the google drive app in gcp 现在在gcp中启用Google Drive应用

from google.cloud import bigquery

client = bigquery.Client()
sql = """
SELECT * FROM `proyect-xxxx.set_xxx.table_x` LIMIT 1000
"""
df = client.query(sql).to_dataframe()

project_id = 'proyect-xxxx'
df = client.query(sql, project=project_id).to_dataframe()
df.head(3)

Exception: invalid: Error while reading table: .... error message: Failed to read the spreadsheet. 异常:无效:读取表时出错:....错误消息:无法读取电子表格。 Errors: No OAuth token with Google Drive scope was found. 错误:未找到具有Google云端硬盘范围的OAuth令牌。

As state by the error you are trying to access Google Drive, Which store you BigQuery external table, without providing permission to your oAuth token 根据错误状态,您正在尝试访问Google Drive,该驱动器存储了BigQuery外部表,但未提供对您的oAuth令牌的许可

You will need to go to Google Console and enable this access to solve your problem. 您需要转到Google控制台并启用此访问权限才能解决您的问题。

You can use this link which provide a how-to explanation on this subject 您可以使用此链接提供有关此主题的操作说明

Visit the Google API Console to obtain OAuth 2.0 credentials such as a client ID and client secret that are known to both Google and your application. 访问Google API控制台以获取OAuth 2.0凭据,例如Google和您的应用程序都知道的客户端ID和客户端密钥。 The set of values varies based on what type of application you are building. 值的集合根据您要构建的应用程序类型而有所不同。 For example, a JavaScript application does not require a secret, but a web server application does. 例如,JavaScript应用程序不需要密码,而Web服务器应用程序则需要密码。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM