Database Reference
In-Depth Information
EXPIRATION_MS = 30 * 24 * 60 * 60 * 1000
def wait(jobs, job_ref):
'''Helper function to block for completion.'''
start = time.time()
done = False
while not done:
time.sleep(10)
result = jobs.get(**job_ref).execute()
print "%s %ds" % (result['status']['state'],
time.time() - start)
done = result['status']['state'] == 'DONE'
if 'errorResult' in result['status']:
raise SystemError(json.dumps(
result['status']['errorResult'], indent=2))
def copy_table(jobs, src, dst):
'''Insert and wait for a copy job with src and
dst.'''
resp = jobs.insert(
projectId=auth.PROJECT_ID,
body={
'configuration': {
'copy': {
'sourceTable': src,
'destinationTable': dst,
'writeDisposition': 'WRITE_TRUNCATE'
}
}
}).execute()
print json.dumps(resp, indent=2)
wait(jobs, resp['jobReference'])
def make_table_ref(table_id):
return {
'projectId': auth.PROJECT_ID,
'datasetId': 'ch11',
'tableId': table_id
Search WWH ::




Custom Search