python读取mysql数据库数据并显示在表格中_如何使用pyqt在表中显示mysql数据库中的数据?...

本文介绍如何使用Python的PyQT库将从MySQL数据库查询到的数据展示在表格中,通过建立数据库连接,执行SQL查询,并将结果填充到QTableWidget中进行显示。
摘要由CSDN通过智能技术生成

我在mysql数据库中有一些数据,我想使用pyqt将其显示到表中,

这是来自数据库的查询(SELECT * FROM MONITORING)。

帮助我在表小部件中显示数据库的内容。

以下是我的程序的源代码: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):

Ma

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值