修改一处过早连接数据库的bug

This commit is contained in:
weiye.wang 2024-04-25 23:44:48 +08:00
parent df227eedb7
commit bdda463b52
1 changed files with 4 additions and 4 deletions

View File

@ -9,10 +9,6 @@ class MyWindow_sxth(QWidget,Ui_Form):
self.database_name = database_name
self.setupUi(self)
self.conditions = []
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor()
mycursor.execute("SELECT count(*) FROM problems WHERE NOT content REGEXP 'OBS';")
self.lcdNumber_resCount.display(mycursor.fetchall()[0][0])
self.bind()
def setdbname(self,string):
self.database_name = string
@ -52,6 +48,10 @@ class MyWindow_sxth(QWidget,Ui_Form):
text += f"字段 {field}{'没有' if flag_not else ''}{''.join([t.strip() for t in matchexp.split(',')])}\n"
self.label_conditions.setText(text)
def exec(self):
mydb = connect(hostname = db_host, port = db_port, username=db_user, pwd=db_pwd, db = self.database_name)
mycursor = mydb.cursor()
mycursor.execute("SELECT count(*) FROM problems WHERE NOT content REGEXP 'OBS';")
self.lcdNumber_resCount.display(mycursor.fetchall()[0][0])
self.matchlist = MatchConditioninMariaDB(self.conditions,self.database_name)
self.lcdNumber_resCount.display(len(self.matchlist))