Database Reference
In-Depth Information
projectId=destination_table_ref['projectId']
).execute()['schema']
page_token = None
while True:
response = self.service.tabledata().list(
pageToken=page_token,
tableId=destination_table_ref['tableId'],
datasetId=destination_table_ref['datasetId'],
projectId=destination_table_ref['projectId']).execute()
page_token = response.get('pageToken', None)
fields = schema.get('fields', [])
rows = response.get('rows', [])
response_handler(fields, rows)
if page_token is None:
# The query is done and there are no more
results
# to read.
break
def main(argv):
if len(argv) == 0:
print('Usage: query_job.py <project_id> [query]')
return
service = auth.build_bq_client()
project_id = argv[0]
query_job = QueryJob(service, project_id)
if len(argv) < 2:
query = 'SELECT 17'
else:
# The entire rest of the command line is the query.
query = ' '.join(argv[1:])
destination = {
'projectId': project_id,
'datasetId': 'scratch',
'tableId': 'results'}
query_job.run(query, destination_table=destination)
if __name__ == "__main__":
main(sys.argv[1:])
Search WWH ::




Custom Search