通过 Python 在 Google App Engine 中查询 Google Bigquery
Query Google Bigquery Through Python In Google App Engine
我正在尝试查询一个大查询 table 并使用 google 应用程序引擎(支持 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)
无论我多么努力,我都没有在本地页面或部署页面上获得结果。
谁能告诉我我哪里做错了什么。
我得到了 py 开发人员的帮助,但真正的问题是我试图通过的 SQL。 group by中间没有space
我正在尝试查询一个大查询 table 并使用 google 应用程序引擎(支持 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)
无论我多么努力,我都没有在本地页面或部署页面上获得结果。
谁能告诉我我哪里做错了什么。
我得到了 py 开发人员的帮助,但真正的问题是我试图通过的 SQL。 group by中间没有space