Esempio n. 1
0
def localizar(id):
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("SELECT * FROM sessao  WHERE id = ?",(id,))
        con.commit()
        lista = rows_to_dict(cur.description, cur.fetchall())
        for sessao in lista:
            cur.execute("select * from sala where id = ?", (sessao['sala_id'],))
            con.commit()
            sessao['sala'] = rows_to_dict(cur.description, cur.fetchall())[0]
        for sessao in lista:
            cur.execute("select * from filme where id = ?", (sessao['filme_id'],))
            con.commit()
            sessao['filme'] = rows_to_dict(cur.description, cur.fetchall())[0]
        return jsonify(lista)
Esempio n. 2
0
def localizarPorFilme(id_filme):
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("select * from sessao where filme_id = ? and data_horario_inicio >= current_timestamp order by data_horario_inicio asc",(id_filme,))
        con.commit()
        lista = rows_to_dict(cur.description, cur.fetchall())
        for sessao in lista:
            cur.execute("select * from sala where id = ?", (sessao['sala_id'],))
            con.commit()
            sessao['sala'] = rows_to_dict(cur.description, cur.fetchall())[0]
        for sessao in lista:
            cur.execute("select * from filme where id = ?", (sessao['filme_id'],))
            con.commit()
            sessao['filme'] = rows_to_dict(cur.description, cur.fetchall())[0]
        print(lista[0])
        return jsonify(lista)
Esempio n. 3
0
def localizar(id):
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("SELECT * FROM usuario  WHERE id = ?", (id, ))
        con.commit()
        lista = rows_to_dict(cur.description, cur.fetchall())
        if (lista == []):
            return jsonify({'Mensagem': 'Nenhum usuario com esse ID'}), 400
        return jsonify(lista)
Esempio n. 4
0
def emcartaz():
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("SELECT * FROM filme where em_cartaz = 1")
        con.commit()
        acabou = False
        while not acabou:
            rows = cur.fetchmany(200)
            acabou = (len(rows) == 0)
            dict = rows_to_dict(cur.description, rows)
            return jsonify(dict)
Esempio n. 5
0
def estreia():
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        print(now)
        cur.execute("SELECT * FROM filme where data_lancamento > ?", (now, ))
        con.commit()
        acabou = False
        while not acabou:
            rows = cur.fetchmany(200)
            acabou = (len(rows) == 0)
            dict = rows_to_dict(cur.description, rows)
            return jsonify(dict)
Esempio n. 6
0
def login(email, senha):
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        if not (type(id)):
            return jsonify({'erro': 'valor(es) inválido(s)'}), 422
        else:
            try:
                cur.execute(
                    "SELECT * FROM usuario WHERE email = ? and senha=?", (
                        email,
                        senha,
                    ))
                con.commit()
                dict = rows_to_dict(cur.description, cur.fetchall())
                if (len(dict) != 0):
                    return localizar(dict[0]['id'])
                else:
                    return jsonify({'Mensagem': 'usuario não encontrado'}), 400
            except Exception as inst:
                return jsonify({'Mensagem': inst.args}), 500
Esempio n. 7
0
def localizarPoltronaIndisponivel(id_sessao):
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("select poltrona from ingresso where sessao_id = ?",(id_sessao,))
        con.commit()
        lista = rows_to_dict(cur.description, cur.fetchall())
        return jsonify(lista)
Esempio n. 8
0
def obterDatasPorFilme(id_filme):
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("select * from sessao where filme_id = ? and data_horario_inicio > current_timestamp group by date(data_horario_inicio);",(id_filme,))
        con.commit()
        lista = rows_to_dict(cur.description, cur.fetchall())
        return jsonify(lista)
Esempio n. 9
0
def listar():
     with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("SELECT * FROM sessao")
        con.commit()
        dict = rows_to_dict(cur.description, cur.fetchall())
        return jsonify(dict)
Esempio n. 10
0
def localizar(id):
    with closing(conectar()) as con, closing(con.cursor()) as cur:
        cur.execute("SELECT * FROM telefone  WHERE id = ?", (id, ))
        con.commit()
        lista = rows_to_dict(cur.description, cur.fetchall())
        return jsonify(lista)