Exemple #1
0
        def queryExecuted(t):
            queryModel.setResult(t.result, t.cursor)
            self.tableQueryResult.setModel(queryModel)

            if self.txtQuery.text().strip().lower().startswith('select'):
                self.labelQueryError.setText("%d rows returned" % t.cursor.rowcount)
            else:
                self.labelQueryError.setText("%d rows affected" % t.cursor.rowcount)

            self.labelQueryTime.setText("Query took %f sec" % t.elapsed_time)
            self.tableQueryResult.resizeColumnsToContents()
            self.tableQueryResult.resizeRowsToContents()

            warningsModel = QPySelectModel(self, self.db)
            warningsModel.setSelect("SHOW WARNINGS")
            warningsModel.select()
            self.tableWarnings.setModel(warningsModel)
            self.tableWarnings.resizeColumnsToContents()
            self.tableWarnings.resizeRowsToContents()

            height = 0
            for i in range(len(warningsModel._rows)):
                height += self.tableWarnings.rowHeight(i) + 2
            if height:
                height += 4
            self.tableWarnings.setMaximumHeight(height)

            queryTerminated()
Exemple #2
0
 def refresh(self):
     queryModel = QPySelectModel(self, self.connection)
     if self.processListInInfoSchema:
         where = "" if self.chkShowIdle.isChecked() else "WHERE STATE != ''"
         queryModel.setSelect(
             "SELECT %s FROM information_schema.PROCESSLIST %s ORDER BY TIME DESC"
             % (",".join(self.processListColumns), where))
     else:
         queryModel.setSelect("SHOW FULL PROCESSLIST")
     queryModel.select()
     self.tableProcessList.setModel(queryModel)
     self.tableProcessList.resizeColumnsToContents()
Exemple #3
0
    def on_btnExecuteQuery_clicked(self):
        self.db.setDatabase(self.dbName)
        queryModel = QPySelectModel(self, self.db)

        def queryTerminated():
            self.btnExecuteQuery.setVisible(True)
            self.btnKillQuery.setVisible(False)

        def queryExecuted(t):
            queryModel.setResult(t.result, t.cursor)
            self.tableQueryResult.setModel(queryModel)

            if self.txtQuery.text().strip().lower().startswith('select'):
                self.labelQueryError.setText("%d rows returned" %
                                             t.cursor.rowcount)
            else:
                self.labelQueryError.setText("%d rows affected" %
                                             t.cursor.rowcount)

            self.labelQueryTime.setText("Query took %f sec" % t.elapsed_time)
            self.tableQueryResult.resizeColumnsToContents()
            self.tableQueryResult.resizeRowsToContents()

            warningsModel = QPySelectModel(self, self.db)
            warningsModel.setSelect("SHOW WARNINGS")
            warningsModel.select()
            self.tableWarnings.setModel(warningsModel)
            self.tableWarnings.resizeColumnsToContents()
            self.tableWarnings.resizeRowsToContents()

            height = 0
            for i in range(len(warningsModel._rows)):
                height += self.tableWarnings.rowHeight(i) + 2
            if height:
                height += 4
            self.tableWarnings.setMaximumHeight(height)

            queryTerminated()

        def queryError(errno, errmsg):
            self.labelQueryError.setText(errmsg)
            self.labelQueryTime.setText("")
            queryTerminated()

        self.labelQueryError.setText("Running query...")
        self.labelQueryTime.setText("")
        self.btnExecuteQuery.setVisible(False)
        self.btnKillQuery.setVisible(True)

        self.queryThread = self.db.asyncQuery(self.txtQuery.text(),
                                              db=self.dbName,
                                              callback=queryExecuted,
                                              callback_error=queryError)
 def refresh(self):
     queryModel = QPySelectModel(self, self.connection)
     if self.processListInInfoSchema:
         where = "" if self.chkShowIdle.isChecked() else "WHERE STATE != ''"
         queryModel.setSelect("SELECT %s FROM information_schema.PROCESSLIST %s ORDER BY TIME DESC" % (",".join(self.processListColumns), where))
     else:
         queryModel.setSelect("SHOW FULL PROCESSLIST")
     queryModel.select()
     self.tableProcessList.setModel(queryModel)
     self.tableProcessList.resizeColumnsToContents()
Exemple #5
0
        def queryExecuted(t):
            queryModel.setResult(t.result, t.cursor)
            self.tableQueryResult.setModel(queryModel)

            if self.txtQuery.text().strip().lower().startswith('select'):
                self.labelQueryError.setText("%d rows returned" %
                                             t.cursor.rowcount)
            else:
                self.labelQueryError.setText("%d rows affected" %
                                             t.cursor.rowcount)

            self.labelQueryTime.setText("Query took %f sec" % t.elapsed_time)
            self.tableQueryResult.resizeColumnsToContents()
            self.tableQueryResult.resizeRowsToContents()

            warningsModel = QPySelectModel(self, self.db)
            warningsModel.setSelect("SHOW WARNINGS")
            warningsModel.select()
            self.tableWarnings.setModel(warningsModel)
            self.tableWarnings.resizeColumnsToContents()
            self.tableWarnings.resizeRowsToContents()

            height = 0
            for i in range(len(warningsModel._rows)):
                height += self.tableWarnings.rowHeight(i) + 2
            if height:
                height += 4
            self.tableWarnings.setMaximumHeight(height)

            queryTerminated()