From a26be896554883917489d248ffa7f63ed8833ed4 Mon Sep 17 00:00:00 2001 From: "weiye.wang" Date: Sun, 14 Apr 2024 19:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=E5=AF=BB=E6=89=BE?= =?UTF-8?q?=E7=A9=BA=E9=97=B2=E9=A2=98=E5=8F=B7=20=E7=9A=84spareIDs?= =?UTF-8?q?=E5=87=BD=E6=95=B0=E4=B8=BA=E6=97=A0=E5=8F=82=E6=95=B0=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 工具v3/database_tools_2.py | 7 +++++-- 工具v3/寻找空闲题号.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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())