Database Reference
In-Depth Information
table = tables.insert(body=table,
**dataset_ref).execute()
# Update the table to add a schema:
table['schema'] = {'fields': [{'name': 'a', 'type':
'string'}]}
table = tables.update(body=table,
**table_ref).execute()
# Patch the table to add a friendly name
patch = {'friendlyName': 'Friendly table'}
table = tables.patch(body=patch,
**table_ref).execute()
# Print table for posterity:
print table
# Find our table in the tables list:
table_list = tables.list(**dataset_ref).execute()
for current in table_list['tables']:
if current['id'] == table['id']: print 'found %s'
% (table['id'])
## And now for some jobs…
config = {'load': {'destinationTable': table_ref}}
load_text = 'first\nsecond\nthird'
# Remember to always name your jobs!
job = {'jobReference': job_ref, 'configuration':
config}
media = MediaIoBaseUpload(io.BytesIO(load_text),
mimetype='application/
octet-stream')
job = jobs.insert(body=job,
media_body=media,
**project_ref).execute()
# List our running or pending jobs:
job_list = jobs.list(
stateFilter=['pending', 'running'],
**project_ref).execute()
print job_list
while job['status']['state'] <> 'DONE':
job = jobs.get(**job_ref).execute()
# Now run a query against that table.
Search WWH ::




Custom Search