def __get_allocations(self): """Retrieves the allocations from the database. """ query = db_session.query(Schedule).all() db_session.close() service_allocations = dict() unit_allocations = dict() for alloc in query: service = (alloc.headcode, alloc.origin_location, alloc.origin_departure) unit = alloc.unit if service not in service_allocations: service_allocations[service] = set() service_allocations[service].add(unit) if unit not in unit_allocations: unit_allocations[unit] = set() unit_allocations[unit].add(service) return (service_allocations, unit_allocations)
def clear_tables(self): db_session.query(ServiceMatching).delete() db_session.commit() db_session.close()
def from_service_matching_pkey(pkey): service_matching = db_session.query(ServiceMatching).get(pkey) db_session.close() if service_matching is not None: return from_service_matching(service_matching)