我想从Google大查询中检索数据。但是用户身份验证并没有发生在我身上。这是我得到的信息。
“访问被拒绝:项目bigquery-public-data:用户sajith-sudhi@adroit-marking-183823.iam.gserviceaccount.com在项目bigquery-public-data中没有bigquery.jobs.create权限”
以下是代码:
from google.cloud import bigquery
from google.oauth2 import service_account
credentials = service_account.Credentials.from_service_account_file(
'NYCTaxi-c81bd00c9864.json')
project_id = 'bigquery-public-data'
client = bigquery.Client(credentials= credentials,project=project_id)
query_job = client.query("""
SELECT *
FROM new_york.tlc_yellow_trips_2016
LIMIT 1000""")
results = query_job.result() # Waits for job to complete.
答案 0 :(得分:1)
在下面的行中,您应该设置自己的项目
project_id = 'bigquery-public-data'
所以它将是
project_id = 'your_project'
在查询本身,你应该添加项目如下
query_job = client.query("""
SELECT *
FROM `bigquery-public-data.new_york.tlc_yellow_trips_2016`
LIMIT 1000""")