Database Reference
In-Depth Information
job_ref['jobId'] = job_id
job = {
'configuration': {'query': query_config},
'jobReference': job_ref
}
print 'Starting query job "%s"' % (job,)
job =
self.service.jobs().insert(projectId=self.project_id,
body=job).execute()
# Fetch the job ID from the running job, in case
one wasn't
# already specified above.
job_ref = job['jobReference']
# Wait for the job to complete.
while job['status']['state'] != 'DONE':
print 'Waiting for job %s to complete: %s' % (
job_ref, job['status']['state'])
time.sleep(1.0)
job = self.service.jobs().get(
jobId = job_ref['jobId'],
projectId = job_ref['projectId']).execute()
if 'errorResult' in job['status']:
print 'Error %s' %
(job['status']['errorResult'],)
return
# Read the results using TableData.list(). Note
that we could
# also read the results using
jobs.getQueryResults(), but for the
# purposes of this sample, we wanted to show the
TableData
# equivalent.
qery_config = job['configuration']['query']
destination_table_ref =
query_config['destinationTable']
schema = self.service.tables().get(
tableId=destination_table_ref['tableId'],
datasetId=destination_table_ref['datasetId'],
Search WWH ::




Custom Search