gpt4 book ai didi

python - BigQuery Python API GET 表

转载 作者:行者123 更新时间:2023-12-01 03:53:35 27 4
gpt4 key购买 nike

我正在尝试使用 BigQuery API Python 库访问我的数据,但似乎无法这样做。我的代码如下。我在代码中使用的数据也被使用了here它在那里工作,但在我的代码中抛出 TypeError: 'HttpRequest' object has no attribute '__getitem__'错误。

如果我只是做 print response相反,输出是 <googleapiclient.http.HttpRequest object at 0x1031d0d50> .

任何帮助将不胜感激。

from apiclient.discovery import build
import logging
from oauth2client.client import GoogleCredentials
logging.basicConfig()
credentials = GoogleCredentials.get_application_default()
bigquery_service = build('bigquery', 'v2', credentials=credentials)
tables = bigquery_service.tables()
response= tables.get(projectId=project_id, datasetId=dataset_id, tableId=table_id)
print response['kind'] #causes TypeError: 'HttpRequest' object has no attribute '__getitem__'

最佳答案

LN 8 末尾缺少 .execute():

[..]
response= tables.get(projectId=project_id, datasetId=dataset_id, tableId=table_id).execute()
[..]

关于python - BigQuery Python API GET 表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37878026/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com