我正在尝试查询bigquery表并使用google apps引擎(启用Biling的项目)将结果显示到网页。我正在使用python(3.4.3)进行开发。这是我找到的代码,我试图通过它,这实际上是我的main.py文件:
import httplib2
from apiclient.discovery import build
from oauth2client.client import SignedJwtAssertionCredentials
# REPLACE WITH YOUR Project ID
PROJECT_ID = "725429XXXXXX"
# REPLACE WITH THE SERVICE ACCOUNT EMAIL FROM GOOGLE DEV CONSOLE
SERVICE_ACCOUNT_EMAIL = '725429XXXXXX-si4unlakcnr3mXXXXXXXXXX@developer.gserviceaccount.com'
f = file('Key.p12', 'rb')
key = f.read()
f.close()
credentials = SignedJwtAssertionCredentials(
SERVICE_ACCOUNT_EMAIL,
key,
scope='https://www.googleapis.com/auth/bigquery')
http = httplib2.Http()
http = credentials.authorize(http)
service = build('bigquery', 'v2', http=http)
datasets = service.datasets()
response = datasets.list(projectId=PROJECT_ID).execute()
print('Dataset list:\n')
for dataset in response['datasets']:
print("%s\n" % dataset['id'])
# SELECT data
query_data = {'query':'
SELECT COUNT(*) FROM [Sample.QCOMMREBATE];
'}
query_request = service.jobs()
query_response = query_request.query(projectId=PROJECT_ID,
body=query_data).execute()
pp.pprint(query_response)
但是我努力尝试我无法在本地页面或部署页面上获得结果。
任何人都可以告诉我,我在任何地方做错了什么。
答案 0 :(得分:0)
我得到了py开发人员的帮助,但真正的问题是我试图通过的SQL。小组之间没有空间。