You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
912 B
28 lines
912 B
|
|
from dao.MysqlConfig import MysqlConfig
|
|
|
|
|
|
class StudentDao:
|
|
|
|
@staticmethod # 增删改的方法
|
|
def update_student(sql, *params):
|
|
try:
|
|
MysqlConfig.cursor.execute(sql, params)
|
|
except Exception as ex:
|
|
print("出现异常:%s" % ex)
|
|
MysqlConfig.db.rollback()
|
|
|
|
@staticmethod # 查询学生的方法
|
|
def query_student(sno):
|
|
sql = "SELECT * FROM t_student WHERE sno = %s" % repr(sno)
|
|
MysqlConfig.cursor.execute(sql) # 执行语句
|
|
MysqlConfig.db.commit() # 提交
|
|
return MysqlConfig.cursor.fetchone() # 返回查询到的结果
|
|
|
|
@staticmethod # 查询全部学生的方法
|
|
def query_all():
|
|
sql = 'SELECT * FROM t_student;'
|
|
MysqlConfig.cursor.execute(sql) # 执行语句
|
|
MysqlConfig.db.commit() # 提交
|
|
return MysqlConfig.cursor.fetchall() # 返回查询到的结果
|