title: How to display data from mysql database in table using pyqt?
body: <p>I've some data in mysql database and I want to display it into table using pyqt,
  this is query from database (<code>SELECT * FROM MONITORING</code>).
  Help me in displaying the contents of database inside the table widget.</p>
  
  <p>Here is source code of my program :</p>
  
  <pre><code>from PyQt4 import QtCore, QtGui
  import sys
  import MySQLdb
  from form.DBConnection import Connection
  import MySQLdb as mdb
  
  db = Connection()
  myCursor = db.name().cursor()
  try:
      _fromUtf8 = QtCore.QString.fromUtf8
  except AttributeError:
      def _fromUtf8(s):
          return s
  
  try:
      _efncoding = QtGui.QApplication.UnicodeUTF8
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig, _encoding)
  except AttributeError:
      def _translate(context, text, disambig):
          return QtGui.QApplication.translate(context, text, disambig)
  
  class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName(_fromUtf8("MainWindow"))
          MainWindow.resize(655, 356)
          self.centralwidget = QtGui.QWidget(MainWindow)
          self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
          self.tbl_anggota = QtGui.QTableWidget(self.centralwidget)
          self.tbl_anggota.setGeometry(QtCore.QRect(15, 40, 511, 192))
          self.tbl_anggota.setObjectName(_fromUtf8("tbl_anggota"))
          self.tbl_anggota.setColumnCount(5)
          self.tbl_anggota.setRowCount(0)
          item = QtGui.QTableWidgetItem()
          self.tbl_anggota.setHorizontalHeaderItem(0, item)
          item = QtGui.QTableWidgetItem()
          self.tbl_anggota.setHorizontalHeaderItem(1, item)
          item = QtGui.QTableWidgetItem()
          self.tbl_anggota.setHorizontalHeaderItem(2, item)
          item = QtGui.QTableWidgetItem()
          self.tbl_anggota.setHorizontalHeaderItem(3, item)
          item = QtGui.QTableWidgetItem()
          self.tbl_anggota.setHorizontalHeaderItem(4, item)
          self.bt_hapus = QtGui.QPushButton(self.centralwidget)
          self.bt_hapus.setGeometry(QtCore.QRect(350, 250, 75, 23))
          self.bt_hapus.setObjectName(_fromUtf8("bt_hapus"))
          MainWindow.setCentralWidget(self.centralwidget)
          self.menubar = QtGui.QMenuBar(MainWindow)
          self.menubar.setGeometry(QtCore.QRect(0, 0, 655, 21))
          self.menubar.setObjectName(_fromUtf8("menubar"))
          MainWindow.setMenuBar(self.menubar)
          self.statusbar = QtGui.QStatusBar(MainWindow)
          self.statusbar.setObjectName(_fromUtf8("statusbar"))
          MainWindow.setStatusBar(self.statusbar)
  
          self.retranslateUi(MainWindow)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
          MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow", None))
          item = self.tbl_anggota.horizontalHeaderItem(0)
          item.setText(_translate("MainWindow", "nim", None))
          item = self.tbl_anggota.horizontalHeaderItem(1)
          item.setText(_translate("MainWindow", "nama", None))
          item = self.tbl_anggota.horizontalHeaderItem(2)
          item.setText(_translate("MainWindow", "jabatan", None))
          item = self.tbl_anggota.horizontalHeaderItem(3)
          item.setText(_translate("MainWindow", "email", None))
          item = self.tbl_anggota.horizontalHeaderItem(4)
          item.setText(_translate("MainWindow", "nohp", None))
          self.bt_hapus.setText(_translate("MainWindow", "Hapus", None))
  
  
  if __name__ == "__main__":
      app = QtGui.QApplication(sys.argv)
      MainWindow = QtGui.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>