Ejemplo n.º 1
0
    def find_by_matriculation_number(self, matriculation_number):
        """Suchen eines Studenten anhand seiner Matrikelnummer."""

        result = []
        cursor = self._cnx.cursor()
        command = "SELECT * FROM student WHERE matriculation_number like '{}'".format(
            matriculation_number)
        cursor.execute(command)
        tuples = cursor.fetchall()

        for (id, user_id, name, course, matriculation_number, mail, google_id, create_time) \
                in tuples:
            student = Student()
            student.set_id(id)
            student.set_user_id(user_id)
            student.set_name(name)
            student.set_course(course)
            student.set_matriculation_number(matriculation_number)
            student.set_mail(mail)
            student.set_google_id(google_id)
            student.set_create_time(create_time)
            result.append(student)

        self._cnx.commit()
        cursor.close()

        return result
    def create_student(self, user_id, name, course, matriculation_number, mail,
                       google_id):
        """Erstellen des Studenten"""

        student = Student()
        student.set_user_id(user_id)
        student.set_name(name)
        student.set_course(course)
        student.set_matriculation_number(matriculation_number)
        student.set_mail(mail)
        student.set_google_id(google_id)
        student.set_id(1)

        with StudentMapper() as mapper:
            return mapper.insert(student)