Пример #1
0
 def FuncConnectDataBase(self):
     try:
         self.database = self.ChooseDataBase.currentText()
         Connect = connection.connecttoserver("localhost","root","mysql123.installer",self.database)
         Connect.commit()
         self.connect.emit(self.database)
         self.close()
     except:
         QMessageBox.information(self,"Warning!","Connection failed!")
Пример #2
0
 def GetTables(self):
     self.Connect = connection.connecttoserver("localhost", "root",
                                               "mysql123.installer",
                                               self.dbname)
     cursor = self.Connect.cursor()
     cursor.execute("SHOW TABLES")
     self.listoftables = cursor.fetchall()
     self.listoftables = [
         i[0] for i in self.listoftables
     ]  #change to list, in we have tables name in some database
Пример #3
0
    def FuncChooseTable(self):
        self.Connect = connection.connecttoserver("localhost", "root",
                                                  "mysql123.installer",
                                                  self.dbname)
        self.cursor = self.Connect.cursor()

        self.table = self.ChooseTable.currentText()
        #take columns names and display to tablewidget
        self.cursor.execute(f"SHOW COLUMNS FROM {self.table}")
        columns = self.cursor.fetchall()
        self.num_of_col = len(columns)
        self.Values.setColumnCount(self.num_of_col)
        for i, columnname in enumerate(columns):
            self.Values.setHorizontalHeaderItem(
                i, QTableWidgetItem(columnname[0]))
Пример #4
0
    def CreateTable(self):
        name = self.NameNewTable.text()
        fields = self.Query.text()
        try:
            Connect = connection.connecttoserver("localhost", "root",
                                                 "mysql123.installer",
                                                 self.dbname)
            cursor = Connect.cursor()
            cursor.execute(f"CREATE TABLE {name} ({fields})")
            Connect.commit()

            QMessageBox.information(self, "Warning!", "SUCCESS!")
            self.close()
        except:
            QMessageBox.information(self, "Warning!", "FAILED!")