【发布时间】:2020-04-04 13:01:04
【问题描述】:
我在 Google BigQuery 中创建了一个数据集并下载了 json 身份验证文件。我正在尝试从 Jupyter Notebook 中的 python 访问此数据集中的表,但出现错误:
“禁止:403 PATCH https://bigquery.googleapis.com/bigquery/v2/projects/testdbt-bigquery-20200403/datasets/landing_zone_flights:访问被拒绝:数据集 testdbt-bigquery-20200403:landing_zone_flights:用户没有数据集 testdbt-bigquery-20200403:landing_zone_flights 的 bigquery.datasets.update 权限。”
代码:
%reload_ext google.cloud.bigquery
import os
from google.cloud import bigquery
print(os.environ['GOOGLE_APPLICATION_CREDENTIALS'])
client = bigquery.Client.from_service_account_json('~/Code/BigQuery/Test_BQ.json')
#get dataset and set permissions as Reader
dataset = client.get_dataset("landing_zone_flights")
entries = list(dataset.access_entries)
full_dataset_id = "{}.{}".format(dataset.project, dataset.dataset_id)
dataset.access_entries = entries
dataset = client.update_dataset(dataset, ["access_entries"]) # Make an API request.
print(
"Updated dataset '{}' with modified user permissions.".format(full_dataset_id)
)
错误是:
禁止:403 补丁 https://bigquery.googleapis.com/bigquery/v2/projects/testdbt-bigquery-20200403/datasets/landing_zone_flights: 拒绝访问:数据集 testdbt-bigquery-20200403:landing_zone_flights: 用户没有数据集的 bigquery.datasets.update 权限 testdbt-bigquery-20200403:landing_zone_flights .
我做错了什么?我能够获取并列出数据集属性,但无法更新或查询任何表
【问题讨论】: