Exemplo n.º 1
0
def consultar_por_nome(nome):
    with closing(con()) as connection, closing(connection.cursor()) as cursor:
        cursor.execute(
            f"SELECT id, nome, id_professor FROM {model_name} WHERE nome = ?",
            (nome, ))
        row = cursor.fetchone()
        if row == None:
            return None
        return Disciplina.criar_com_id(row[0], row[1], row[2])
Exemplo n.º 2
0
def consultar_alunos(disciplina):
    with closing(con()) as connection, closing(connection.cursor()) as cursor:
        cursor.execute(
            f"SELECT id, disciplina_id, aluno_id FROM {model_name} WHERE nome = ?",
            (disciplina, ))
        row = cursor.fetchone()
        if row == None:
            return None
        return Disciplina.criar_com_id(row[0], row[1], row[2])
Exemplo n.º 3
0
def listar():
    with closing(con()) as connection, closing(connection.cursor()) as cursor:
        cursor.execute(f"SELECT id, nome, id_professor FROM {model_name}")
        rows = cursor.fetchall()
        registros = []
        for (id, nome, id_professor) in rows:
            disciplina = Disciplina.criar_com_id(id, nome, id_professor)
            if disciplina != None:
                registros.append(disciplina)
        return registros