Guest User

Untitled

a guest
Oct 22nd, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. class ExampleApp(QtWidgets.QMainWindow, design.Ui_MainWindow):
  2. def __init__(self):
  3.  
  4. super().__init__()
  5. self.setupUi(self)
  6. self.connect_mysql.clicked.connect(self.on_click)
  7. self.dialog = MainMenu()
  8. def on_click(self):
  9. try:
  10. ip = self.ip.text()
  11. user = self.user.text()
  12. password = self.password.text()
  13. port = self.port.text()
  14. db = self.db.text()
  15. mydb = mysql.connector.connect(
  16. host=ip,
  17. user=user,
  18. passwd=password,
  19. database=db
  20. )
  21. mycursor = mydb.cursor()
  22. self.close()
  23. self.dialog.show()
  24.  
  25. except:
  26. QMessageBox.about(self, "Message", "Something went wrong...")
Add Comment
Please, Sign In to add comment