connect mysql.
This commit is contained in:
parent
902aaae6c0
commit
d96d8c8786
49
dm.py
49
dm.py
@ -47,27 +47,27 @@ class TableWidgetExample(QMainWindow):
|
|||||||
header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
|
header.setSectionResizeMode(QtWidgets.QHeaderView.ResizeToContents)
|
||||||
header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
|
header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch)
|
||||||
|
|
||||||
data = [
|
# data = [
|
||||||
["https://baidu.com", "队列中"],
|
# ["https://baidu.com", "队列中"],
|
||||||
["https://google.com", "队列中"],
|
# ["https://google.com", "队列中"],
|
||||||
["https://rainss.cn", "队列中"],
|
# ["https://rainss.cn", "队列中"],
|
||||||
["https://baidu.com", "队列中"],
|
# ["https://baidu.com", "队列中"],
|
||||||
["https://google.com", "队列中"],
|
# ["https://google.com", "队列中"],
|
||||||
["https://rainss.cn", "队列中"],
|
# ["https://rainss.cn", "队列中"],
|
||||||
["https://baidu.com", "队列中"],
|
# ["https://baidu.com", "队列中"],
|
||||||
["https://google.com", "队列中"],
|
# ["https://google.com", "队列中"],
|
||||||
["https://rainss.cn", "队列中"],
|
# ["https://rainss.cn", "队列中"],
|
||||||
["https://baidu.com", "队列中"],
|
# ["https://baidu.com", "队列中"],
|
||||||
["https://google.com", "队列中"],
|
# ["https://google.com", "队列中"],
|
||||||
["https://rainss.cn", "队列中"]
|
# ["https://rainss.cn", "队列中"]
|
||||||
]
|
# ]
|
||||||
|
#
|
||||||
table.setRowCount(len(data))
|
# table.setRowCount(len(data))
|
||||||
|
#
|
||||||
for row, rowData in enumerate(data):
|
# for row, rowData in enumerate(data):
|
||||||
for col, value in enumerate(rowData):
|
# for col, value in enumerate(rowData):
|
||||||
item = QTableWidgetItem(value)
|
# item = QTableWidgetItem(value)
|
||||||
table.setItem(row, col, item)
|
# table.setItem(row, col, item)
|
||||||
|
|
||||||
top_layout.addWidget(table)
|
top_layout.addWidget(table)
|
||||||
center_layout.addWidget(top_widget)
|
center_layout.addWidget(top_widget)
|
||||||
@ -102,6 +102,7 @@ class TableWidgetExample(QMainWindow):
|
|||||||
|
|
||||||
connection_layout.addWidget(self.connection_host)
|
connection_layout.addWidget(self.connection_host)
|
||||||
connection_layout.addWidget(self.connection_port)
|
connection_layout.addWidget(self.connection_port)
|
||||||
|
connection_layout.addWidget(self.connection_dbname)
|
||||||
connection_layout.addWidget(self.connection_user)
|
connection_layout.addWidget(self.connection_user)
|
||||||
connection_layout.addWidget(self.connection_pwd)
|
connection_layout.addWidget(self.connection_pwd)
|
||||||
connection_layout.addWidget(self.button_connection)
|
connection_layout.addWidget(self.button_connection)
|
||||||
@ -124,9 +125,9 @@ class TableWidgetExample(QMainWindow):
|
|||||||
pwd = self.connection_pwd.text()
|
pwd = self.connection_pwd.text()
|
||||||
dbname = self.connection_dbname.text()
|
dbname = self.connection_dbname.text()
|
||||||
|
|
||||||
if not host or not port or not user or not pwd:
|
if not host or not port or not dbname or not user or not pwd:
|
||||||
self.statusBar().showMessage("主机、端口、用户名和密码不能为空!")
|
self.statusBar().showMessage("主机、端口、数据库名、用户名和密码不能为空!")
|
||||||
QMessageBox.critical(self, "Error", "主机、端口、用户名和密码不能为空!")
|
QMessageBox.critical(self, "Error", "主机、端口、数据库名、用户名和密码不能为空!")
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user