Example #1
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
Example #2
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
Example #3
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