Пример #1
0
def objeto_list():
    resp = None
    status = 200
    try:
        conn = engine.connect()
        stmt = select([Objeto])
        rs = conn.execute(stmt)
        lista = []
        for r in conn.execute(stmt):
            print(r.fecha_hallado)
            row = {
                'id': r.id,
                'cod_objeto': r.cod_objeto,
                'nom_objeto': r.nom_objeto,
                'categoria': r.categoria,
                'estado': r.estado,
                'marca': r.marca,
                'fecha_hallado': str(r.fecha_hallado),
                'fecha_dev': str(r.fecha_dev),
                'lugar': r.lugar,
                'nro_anaquel': r.nro_anaquel,
                'caract_esp': r.caract_esp,
                'cod_usu_entrega': r.cod_usu_entrega
            }
            lista.append(row)
        #resp = [dict(r) for r in conn.execute(stmt)]
        resp = lista
    except Exception as e:
        resp = ['Se ha producido un error en listar los paises', str(e)]
        status = 500

    return json.dumps(resp), status
Пример #2
0
def countries_list():  # SELECT * FROM countries
    try:
        conn = engine.connect()
        stmt = select([Country])
        rs = conn.execute(stmt)
        resp = [dict(r) for r in conn.execute(stmt)]
        print(resp)
    except Exception as e:
        print(str(e))
Пример #3
0
def get_rol_by_id(id):  # SELECT rol FROM usuario WHERE cod_usuario = :id
    try:
        conn = engine.connect()
        stmt = select([Usuario]).where(Usuario.cod_usuario == id)
        rs = conn.execute(stmt)
        resp = [dict(r) for r in conn.execute(stmt)]
        return (resp[0]['rol'])
    except Exception as e:
        return (str(e))
Пример #4
0
def get_country_name_by_id(id):  # SELECT name FROM countries WHERE id = :id
    try:
        conn = engine.connect()
        stmt = select([Country]).where(Country.id == id)
        rs = conn.execute(stmt)
        resp = [dict(r) for r in conn.execute(stmt)]
        print(resp[0]['name'])
    except Exception as e:
        print(str(e))
Пример #5
0
def objeto_list():
    try:
        conn = engine.connect()
        stmt = select([Objeto])
        rs = conn.execute(stmt)
        resp = [dict(r) for r in conn.execute(stmt)]
        return resp

    except Exception as e:
        return (str(e))
Пример #6
0
def usuario_list():  # SELECT * FROM countries
    try:
        conn = engine.connect()
        stmt = select([Usuario])
        rs = conn.execute(stmt)
        resp = [dict(r) for r in conn.execute(stmt)]
        print(resp)
        return resp
    except Exception as e:
        print(str(e))
Пример #7
0
def country_list():
    resp = None
    status = 200
    try:
        conn = engine.connect()
        stmt = select([Country])
        rs = conn.execute(stmt)
        resp = [dict(r) for r in conn.execute(stmt)]
    except Exception as e:
        resp = ['Se ha producido un error en listar los paises', str(e)]
        status = 500
    return json.dumps(resp), status
Пример #8
0
def buscar():
    print("aaaaaa")
    lugar = str(request.form['lugar'])
    categoria = str(request.form['categoria'])
    fecha_inicio = request.form['trip-inicio']
    print(fecha_inicio)
    fecha_fin = request.form['trip-fin']
    #dt_object1 =datetime.strptime(fecha_inicio, '%Y-%m-%d')
    #dt_object2 =datetime.strptime(fecha_fin, '%Y-%m-%d')
    resp = None
    status = 200
    try:
        conn = engine.connect()
        stmt = select([Objeto])
        rs = conn.execute(stmt)
        lista = []
        for r in conn.execute(stmt):
            print(fecha_inicio)
            row = {
                'id': r.id,
                'cod_objeto': r.cod_objeto,
                'nom_objeto': r.nom_objeto,
                'categoria': r.categoria,
                'estado': r.estado,
                'marca': r.marca,
                'fecha_hallado': str(r.fecha_hallado),
                'fecha_dev': str(r.fecha_dev),
                'lugar': r.lugar,
                'nro_anaquel': r.nro_anaquel,
                'caract_esp': r.caract_esp,
                'cod_usu_entrega': r.cod_usu_entrega
            }
            if r.categoria == categoria or r.lugar == lugar:
                lista.append(row)

        rpta = lista
    except Exception as e:
        rpta = ['Se ha producido un error en listar los paises', str(e)]
        status = 500

    return json.dumps(rpta), status