From d96d8c87863a1dfc478666c02faaa4dec80fbd4f Mon Sep 17 00:00:00 2001 From: rainerosion Date: Sun, 10 Sep 2023 17:13:33 +0800 Subject: [PATCH] connect mysql. --- dm.py | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/dm.py b/dm.py index fde271e..a0842a8 100644 --- a/dm.py +++ b/dm.py @@ -47,27 +47,27 @@ class TableWidgetExample(QMainWindow): header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents) header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch) - data = [ - ["https://baidu.com", "队列中"], - ["https://google.com", "队列中"], - ["https://rainss.cn", "队列中"], - ["https://baidu.com", "队列中"], - ["https://google.com", "队列中"], - ["https://rainss.cn", "队列中"], - ["https://baidu.com", "队列中"], - ["https://google.com", "队列中"], - ["https://rainss.cn", "队列中"], - ["https://baidu.com", "队列中"], - ["https://google.com", "队列中"], - ["https://rainss.cn", "队列中"] - ] - - table.setRowCount(len(data)) - - for row, rowData in enumerate(data): - for col, value in enumerate(rowData): - item = QTableWidgetItem(value) - table.setItem(row, col, item) + # data = [ + # ["https://baidu.com", "队列中"], + # ["https://google.com", "队列中"], + # ["https://rainss.cn", "队列中"], + # ["https://baidu.com", "队列中"], + # ["https://google.com", "队列中"], + # ["https://rainss.cn", "队列中"], + # ["https://baidu.com", "队列中"], + # ["https://google.com", "队列中"], + # ["https://rainss.cn", "队列中"], + # ["https://baidu.com", "队列中"], + # ["https://google.com", "队列中"], + # ["https://rainss.cn", "队列中"] + # ] + # + # table.setRowCount(len(data)) + # + # for row, rowData in enumerate(data): + # for col, value in enumerate(rowData): + # item = QTableWidgetItem(value) + # table.setItem(row, col, item) top_layout.addWidget(table) center_layout.addWidget(top_widget) @@ -102,6 +102,7 @@ class TableWidgetExample(QMainWindow): connection_layout.addWidget(self.connection_host) connection_layout.addWidget(self.connection_port) + connection_layout.addWidget(self.connection_dbname) connection_layout.addWidget(self.connection_user) connection_layout.addWidget(self.connection_pwd) connection_layout.addWidget(self.button_connection) @@ -124,9 +125,9 @@ class TableWidgetExample(QMainWindow): pwd = self.connection_pwd.text() dbname = self.connection_dbname.text() - if not host or not port or not user or not pwd: - self.statusBar().showMessage("主机、端口、用户名和密码不能为空!") - QMessageBox.critical(self, "Error", "主机、端口、用户名和密码不能为空!") + if not host or not port or not dbname or not user or not pwd: + self.statusBar().showMessage("主机、端口、数据库名、用户名和密码不能为空!") + QMessageBox.critical(self, "Error", "主机、端口、数据库名、用户名和密码不能为空!") return try: