1

I'm trying to access my data using the BigQuery API Python Library but can't seem to do so. My code is below. The data that I used in the code was also used here and it worked there but in my code throws a TypeError: 'HttpRequest' object has no attribute '__getitem__' error.

If I just do a print response instead, output is <googleapiclient.http.HttpRequest object at 0x1031d0d50>.

Any help will be much appreciated.

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__'
4
  • Have you debugged the response object ? I think tables.get wont return the desired output Commented Jun 17, 2016 at 11:20
  • Try to add unicode methods to your function Commented Jun 17, 2016 at 11:21
  • 1
    @Kalanamith I'm not too sure how one would go about debugging the response object? By adding unicode methods, do you mean, unicode(project_id) , unicode(dataset_id) etc ? If so, then I just tried that but to no avail :( Commented Jun 18, 2016 at 3:31
  • docs.python-requests.org/en/master/api this has indepth insights on debugging and its possible Commented Jun 20, 2016 at 6:32

1 Answer 1

2

You are missing .execute() at the end of LN 8:

[..]
response= tables.get(projectId=project_id, datasetId=dataset_id, tableId=table_id).execute()
[..]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.