Database Reference
In-Depth Information
for row in rows:
line = []
for i in xrange(0, len(schema)):
cell = row['f'][i]
field = schema[i]
line.append({field['name']: cell['v']})
pprint.pprint(line)
class QueryRpc:
def __init__(self, service, project_id):
self.service = service
self.project_id = project_id
def run(self, query, response_handler=print_results,
timeout_ms=30*1000, max_results=1024):
'''Run a query RPC and print the results.
query: text of query to run.
response_handler: function that is used to
process results.
timeout_ms: timeout of each RPC call.
max_results: maximum number of results to
process.
'''
query_request = {
'query': query,
# Use a timeout of 0, which means we'll
always need
# to get results via getQueryResults().
'timeoutMs': 0,
'maxResults': max_results
}
# Start the query.
response = self.service.jobs().query(
projectId=self.project_id,
body=query_request).execute()
job_ref = response['jobReference']
while True:
page_token = response.get('pageToken', None)
query_complete = response.get('jobComplete',
False)
Search WWH ::




Custom Search