def insert_or_update_single_table_attribute(device_slug, shot_number, shot_timestamp, attribute_slug): cursor = get_summary_cursor() table_name = TABLE_NAME_TEMPLATE.format(device_slug) if shot_exists(cursor, table_name, shot_number): update_single_table_attribute(device_slug, shot_number, shot_timestamp, attribute_slug) else: insert_single_table_attribute(device_slug, shot_number, shot_timestamp, attribute_slug)
def __init__(self, device): """Interface to a summary database table. Args: device - an instance of h1ds.models.Device """ self.device = device self.table_name = TABLE_NAME_TEMPLATE.format(device.slug) if not self.table_exists(): self.create_table()
def update_single_table_attribute(device_slug, shot_number, shot_timestamp, attribute_slug): """Get a data for a single summary attribute and write it to the table. Arguments: device slug (str) - slug for device shot_number (int) - shot number attribute_slug (str) - slug for SummaryAttribute for device. """ table_name = TABLE_NAME_TEMPLATE.format(device_slug) chord([get_summary_attribute_data.s(device_slug, shot_number, attribute_slug)], update_table_attributes.s(table_name=table_name, shot_number=shot_number,shot_timestamp=shot_timestamp)).apply_async()