예제 #1
0
	def getCourseInfo(student_id):
		conn = Connection.getConnection()
		cursor = conn.cursor()
		sql = "select * from course where course_id in \
			(select course_id from selection where student_id = %d)"%(student_id)
		cursor.execute(sql)
		return cursor.fetchall()
예제 #2
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]
예제 #3
0
    def getStudentIdByUserName(username):
        conn = Connection.getConnection()
        cursor = conn.cursor()
        sql = "select student_id from student_account where username = '******'" % (
            username)
        cursor.execute(sql)

        return cursor.fetchone()[0]
예제 #4
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]
예제 #5
0
    def isAccountValid(username, password):
        connection = Connection.getConnection()
        cursor = connection.cursor()
        sql = "select * from student_account where username = '******' and password = '******'" % (
            username, password)
        cursor.execute(sql)
        resultList = cursor.fetchall()

        return len(resultList) == 1
예제 #6
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"已经选过该课程")
예제 #7
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"没有选择该课程")
예제 #8
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()
예제 #9
0
	def getAllCourseInfo():
		conn = Connection.getConnection()
		cursor = conn.cursor()
		sql = "select * from course"
		cursor.execute(sql)
		return cursor.fetchall()
예제 #10
0
# 生成账号信息
student_accounts = []
for i in range(0, 100):
	student_accounts.append((student_id[i], 'test', student_id[i]))

# 生成工号
teacher_ids = np.arange(1, 11, 1)
	
# 随机生成教师信息
teacher_infos = []
for i in range(0, 10):
	teacher_infos.append((teacher_ids[i], createName(), \
		createGender(), u'电子科学与工程学院', \
		createRank(), createPhoneNum()))

conn = Connection.getConnection()
cursor = conn.cursor()
cursor.execute("select * from teach")
resultList = cursor.fetchall()

# 生成课程信息
course_infos = [\
	(1, u'计算方法', u'仙林校区 逸B-105', u'周二 第5-7节 1-18周', u'选修', u'电子科学与工程学院'), \
	(2, u'微波测量实验', u'仙林校区 仙林电子楼239室', u'周五 第5-6节 1-18周', u'核心', u'电子科学与工程学院'), \
	(3, u'操作系统', u'仙林校区 仙Ⅰ-115', u'周一 第3-4节 1-18周', u'选修', u'电子科学与工程学院'), \
	(4, u'矩阵计算与应用', u'仙林校区 仙Ⅰ-115', u'周一 第9-10节 1-18周', u'选修', u'电子科学与工程学院'), \
	(5, u'IT企业创业与发展战略', u'仙林校区 仙Ⅱ-304', u'	周二 第9-10节 1-18周', u'选修', u'电子科学与工程学院'), \
	(6, u'数据通信', u'仙林校区 仙Ⅰ-206', u'	周四 第5-7节 1-18周', u'选修', u'电子科学与工程学院'), \
	(7, u'微电子工艺', u'仙林校区 仙Ⅰ-104', u'周一 仙Ⅰ-104 1-18周', u'选修', u'电子科学与工程学院'), \
	(8, u'数字集成电路设计', u'仙林校区 仙Ⅰ-115', u'周一 第5-7节 1-12周', u'选修', u'电子科学与工程学院'), \
	(9, u'电子系统实践', u'仙林校区 仙Ⅰ-115 ', u'周一 第5-7节 1-12周', u'选修', u'电子科学与工程学院'), \
예제 #11
0
	def getAllStudentInfo():
		conn = Connection.getConnection()
		cursor = conn.cursor()
		sql = "select * from student"
		cursor.execute(sql)
		return cursor.fetchall()