2016-06-17 15 views
0

BigQuery API Pythonライブラリを使用してデータにアクセスしようとしていますが、そうは思われません。私のコードは以下の通りです。コードで使用したデータもhereで使用されていましたが、コードではTypeError: 'HttpRequest' object has no attribute '__getitem__'というエラーがスローされます。BigQuery Python API GETテーブル

代わりに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__' 
+0

あなたはレスポンスオブジェクトをデバッグがありますか?私はtables.getは望みの出力を返しません。 – Kalanamith

+0

あなたの関数に__unicode__メソッドを追加しようとします。 – Kalanamith

+1

@Kalanamith私は応答オブジェクトをデバッグする方法についてはあまりよく分かりませんか? ユニコードメソッドを追加すると、 'unicode(project_id)'、 'unicode(dataset_id)'などの意味ですか?もしそうなら、私はちょうどそれを試みたが役に立たなかった:( – niknation

答えて

1

あなたはLN 8の終わりに.execute()が欠落しています

[..] 
response= tables.get(projectId=project_id, datasetId=dataset_id, tableId=table_id).execute() 
[..] 
関連する問題