def ListarProfessores(self, codigoEscola): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT * FROM Professor WHERE codEscola = ? """, (codigoEscola, )) aux = list() res = cursor.fetchall() for i in res: cursor.execute( """ SELECT * FROM ProfessorTurma WHERE matriculaProfessor = ? """, (i[1], )) aux2 = list() for j in cursor.fetchall(): aux2.append(turma.Turma(j[0], j[1])) aux.append(professor.Professor(i[0], i[1], i[2], i[3], aux2)) conn.close() return aux
def ListarAllStudents(self): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute(""" SELECT * FROM Student """) aux = list() res = cursor.fetchall() for i in res: cursor.execute( """ SELECT * FROM StudentTurma WHERE matriculaStudent = ? """, (i[1], )) aux2 = list() for j in cursor.fetchall(): aux2.append(turma.Turma(j[0], j[1])) aux.append( student.Student(i[0], i[1], i[2], i[3], i[4], i[5], aux2)) conn.close() return aux
def GetStudentByMatricula(self, matricula): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT * FROM Student WHERE matricula = ? """, (matricula, )) res = cursor.fetchall() cursor.execute( """ SELECT * FROM StudentTurma WHERE matriculaStudent = ? """, (matricula, )) aux = list() for i in cursor.fetchall(): aux.append(turma.Turma(i[1], i[2])) conn.close() if (len(res) != 0): return student.Student(res[0][0], res[0][1], res[0][2], res[0][3], res[0][4], res[0][5], aux) return None
def GetStudentByTurma(self, codigo, codigoDisc): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT name, matricula, password, codEscola, Student.periodo, codCurso FROM Student, StudentTurma WHERE matriculaStudent = matricula AND codigoTurma = ? AND codigoDisc = ? """, (codigo, codigoDisc)) aux = list() res = cursor.fetchall() for i in res: cursor.execute( """ SELECT * FROM StudentTurma WHERE matriculaStudent = ? """, (i[1], )) aux2 = list() for j in cursor.fetchall(): aux2.append(turma.Turma(j[0], j[1])) aux.append( student.Student(i[0], i[1], i[2], i[3], i[4], i[5], aux2)) conn.close() return aux
def GetProfessor(self, username, password): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT * FROM Professor WHERE matricula = ? AND password = ? """, (username, password)) res = cursor.fetchall() cursor.execute( """ SELECT * FROM ProfessorTurma WHERE matriculaProfessor = ? """, (username, )) aux = list() for i in cursor.fetchall(): aux.append(turma.Turma(i[1], i[2])) conn.close() if (len(res) != 0): return professor.Professor(res[0][0], res[0][1], res[0][2], res[0][3], aux) return None
def GetCursoGraByCod(self, codigo): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT * FROM Graduacao WHERE codigo = ? """, (codigo, )) aux = cursor.fetchall() conn.close() if (len(aux) != 0): return turma.Turma(aux[0][0], aux[0][1]) return None
def ListarTurma(self, codigoEscola): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT Turma.codigo, codigoDisc FROM Turma, Disciplina WHERE Turma.codigoDisc = Disciplina.codigo AND Disciplina.codEscola = ? """, (codigoEscola, )) aux = list() for i in cursor.fetchall(): aux.append(turma.Turma(i[0], i[1])) conn.close() return aux
def GetTurmaDisc(self, disc): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT * FROM Turma WHERE codigoDisc = ? """, (disc, )) aux = list() for i in cursor.fetchall(): aux.append(turma.Turma(i[0], i[1])) conn.close() return aux
def GetTurmaStudent(self, user): conn = sqlite3.connect('university.db') cursor = conn.cursor() cursor.execute( """ SELECT * FROM StudentTurma WHERE matriculaStudent = ? AND periodo = ? """, (user.matricula, user.periodo)) aux = list() for i in cursor.fetchall(): aux.append(turma.Turma(i[1], i[2])) conn.close() return aux