diff --git a/工具v3/database_tools_2.py b/工具v3/database_tools_2.py index acf9a4ba..531a1b91 100644 --- a/工具v3/database_tools_2.py +++ b/工具v3/database_tools_2.py @@ -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()] diff --git a/工具v3/寻找空闲题号.py b/工具v3/寻找空闲题号.py index fe465073..05e57a29 100644 --- a/工具v3/寻找空闲题号.py +++ b/工具v3/寻找空闲题号.py @@ -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())