Database Reference
In-Depth Information
}
def load_device_data(jobs, dst):
# This method simulates loading data from datastore
by
# simply copying a sample table to a new location.
copy_table(
jobs,
src=make_table_ref('devices'),
dst=dst)
def load_and_backup(bq, date):
# Get the latest data.
daily = make_table_ref('devices_' +
date.strftime('%Y%m%d'))
load_device_data(bq.jobs(), daily)
# Make the snapshot representing the latest.
current = daily.copy()
current['tableId'] = 'devices_current'
copy_table(bq.jobs(), daily, current)
quarters = {
'0331': 1,
'0630': 2,
'0930': 3,
'1231': 4
}
quarter = quarters.get(date.strftime('%m%d'), None)
if quarter:
quarterly = daily.copy()
quarterly['tableId'] = (
'devices_%dq%d' % (date.year, quarter))
copy_table(bq.jobs(), daily, quarterly)
# Finally set the daily version to expire.
bq.tables().patch(
body={
Search WWH ::




Custom Search