修改 寻找空闲题号 的spareIDs函数为无参数函数

This commit is contained in:
weiye.wang 2024-04-14 19:16:18 +08:00
parent aa343a9cdc
commit a26be89655
2 changed files with 6 additions and 3 deletions

View File

@ -22,6 +22,9 @@ BuildFullScheme = {
}
}
def connect(hostname,port,username,pwd,db):
mydb = mysql.connector.connect(host = hostname, port = port, user = username, password = pwd, database = db)
return mydb
def GetDate(): #获得当前日期
currentdate = str(time.localtime().tm_year)+str(time.localtime().tm_mon).zfill(2)+str(time.localtime().tm_mday).zfill(2)
@ -254,8 +257,8 @@ def extractIDs(filePath): #提取.txt,.tex或.pdf文件中的题号, 返回含
return generate_exp(ids)
def spareIDs(host,port,username,password): #返回空闲题号
mydb = mysql.connector.connect(host = host, port = port, user=username, password=password, database = "tikutest")
def spareIDs(): #返回空闲题号, 已更新为适合mariadb的版本
mydb = connect(hostname = "wwylss.synology.me", port = "13306", username="root", pwd="Wwy@0018705", db = "tikutest")
mycursor = mydb.cursor()
mycursor.execute("SELECT ID FROM problems;")
idlist = [ret[0] for ret in mycursor.fetchall()]

View File

@ -12,7 +12,7 @@ class MyWindow(QWidget,Ui_Form):
def ShowAvailable(self):
self.label_Available.setText(spareIDs("wwylss.synology.me","13306","root","Wwy@0018705"))
self.label_Available.setText(spareIDs())