Database Reference
In-Depth Information
tabledata = service.tabledata()
jobs = service.jobs()
# Generate some IDs to use with the tour.
tour = 'tour_%d' % (time.time())
dataset_id = 'dataset_' + tour
table_id = 'table_' + tour
job_id = 'job_' + tour
project_ref = {'projectId': project_id}
dataset_ref = {'datasetId': dataset_id,
'projectId': project_id}
table_ref = {'tableId': table_id,
'datasetId': dataset_id,
'projectId': project_id}
job_ref = {'jobId': job_id,
'projectId': project_id}
# First, find the project and print out the friendly
name.
for project in projects.list().execute()['projects']:
if (project['id'] == project_id):
print 'Found %s: %s' % (project_id,
project['friendlyName'])
# Now create a dataset
dataset = {'datasetReference': dataset_ref}
dataset = datasets.insert(body=dataset,
**project_ref).execute()
# Patch the dataset to set a friendly name.
update = {'friendlyName': 'Tour dataset'}
dataset = datasets.patch(body=update,
**dataset_ref).execute()
# Print out the dataset for posterity
print '%s' % (dataset,)
# Find our dataset in the datasets list:
dataset_list = datasets.list(**project_ref).execute()
for current in dataset_list['datasets']:
if current['id'] == dataset['id']:
print 'found %s' % (dataset['id'])
### Now onto tables…
table = {'tableReference': table_ref}
Search WWH ::




Custom Search