예제 #1
0
    def getStudentsByClassId(self, classId):
        sql = "SELECT * FROM student WHERE ClassId = %s"
        value = (classId, )

        self.cursor.execute(sql, value)

        try:
            obj = self.cursor.fetchall()
            return Student.CreateStudent(obj)
        except mysql.connector.Error as err:
            print("Error : ", err)
예제 #2
0
    def getStudentById(self, id):
        sql = "SELECT * FROM student WHERE Id = %s"
        value = (id, )

        self.cursor.execute(sql, value)

        try:
            obj = self.cursor.fetchone()
            return Student.CreateStudent(obj)
        except mysql.connector.Error as err:
            print("Error : ", err)