def service_get(service_id, session=None): result = model_query(service_models.Service, session=session). \ filter_by(id=service_id). \ first() if not result: raise exception.ServiceNotFound(service_id=service_id) return result
def count_insert_or_update(name, url): print name, url session = get_session() result = model_query(APICount, session=session). \ filter_by(name=name). \ filter_by(url=url). \ first() if not result: with session.begin(): result = APICount() result.update({'name': name, 'url': url, 'count': 1}) result.save() else: result.count += 1 result.save(session=session) return result
def service_get_by_args(host, binary): return model_query(service_models.Service). \ filter_by(host=host). \ filter_by(binary=binary). \ first()
def count_list(): return model_query(APICount).all()
def service_list(): return model_query(service_models.Service).all()