示例#1
0
    def find_by_user_id(self, user_id):
        """Suchen eines Studenten anhand der User_ID."""

        result = []
        cursor = self._cnx.cursor()
        command = "SELECT * FROM student WHERE user_id like '{}'".format(
            user_id)
        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
示例#2
0
    def find_all(self):
        """Auslesen aller Studenten"""

        result = []
        cursor = self._cnx.cursor()
        command = "SELECT * FROM student"
        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
示例#3
0
    def find_by_key(self, id):
        """Suchen eines Studenten mit vorgegebener ID"""

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

        if len(tuples) != 0:

            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)
                result = student

        else:
            result = None

        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)