コード例 #1
0
 def getSelectStudentNum(courseId):
     conn = Connection.getConnection()
     cursor = conn.cursor()
     sql = "select count(*) from selection where course_id = %d" % (
         courseId)
     cursor.execute(sql)
     return cursor.fetchone()[0]
コード例 #2
0
 def getSelectCourseInfo(studentId):
     conn = Connection.getConnection()
     cursor = conn.cursor()
     sql = "select * from course where course_id in (select course_id from selection where student_id = %d)" % (
         studentId)
     cursor.execute(sql)
     return cursor.fetchall()
コード例 #3
0
 def getSelectCourseNum(studentId):
     conn = Connection.getConnection()
     cursor = conn.cursor()
     sql = "select count(*) from selection where student_id = %d" % (
         studentId)
     cursor.execute(sql)
     result = cursor.fetchone()
     return result[0]
コード例 #4
0
    def quitCourse(student_id, course_id):
        conn = Connection.getConnection()
        cursor = conn.cursor()
        sql = "select * from selection \
			where student_id=%d and course_id=%d" % (student_id, course_id)
        cursor.execute(sql)

        if (len(cursor.fetchall()) > 0):
            sql = "delete from selection \
				where student_id=%d and course_id=%d" % (student_id, course_id)
            cursor.execute(sql)
            conn.commit()
            return ('1', u"成功退选该课程")
        else:
            return ('0', u"没有选择该课程")
コード例 #5
0
    def selectCourse(student_id, course_id):
        conn = Connection.getConnection()
        cursor = conn.cursor()
        sql = "select * from selection \
			where student_id=%d and course_id=%d" % (student_id, course_id)
        cursor.execute(sql)

        if (len(cursor.fetchall()) == 0):
            sql = "insert into selection values(%d, %d)" % (student_id,
                                                            course_id)
            cursor.execute(sql)
            conn.commit()
            return ('1', u"成功选择该课程")
        else:
            return ('0', u"已经选过该课程")
コード例 #6
0
 def getAllStudentInfo():
     conn = Connection.getConnection()
     cursor = conn.cursor()
     sql = "select * from student"
     cursor.execute(sql)
     return cursor.fetchall()
コード例 #7
0
 def getCourseInfoById(id):
     conn = Connection.getConnection()
     cursor = conn.cursor()
     sql = "select * from course where course_id = %d" % (id)
     cursor.execute(sql)
     return cursor.fetchall()
コード例 #8
0
 def getAllCourseInfo():
     conn = Connection.getConnection()
     cursor = conn.cursor()
     sql = "select * from course"
     cursor.execute(sql)
     return cursor.fetchall()