I am a Python and QT newbie. I am trying to do a little app with PyQT4 in order to supervise a home MySQL server of mine, so my first idea was to do the classic SHOW PROCESSLIST
, parse it, and show in a pretty UI. Nothing big, really.
But for some reason, the QtSql module doesn't return anything when doing this query, although it works with other queries like SHOW TABLES
, etc
I found an old (2002) message in a mailing list talking about this[1], and a reference in the MythTV code[2], but none of them explains it clearly.
Here is some code:
db = QSqlDatabase.addDatabase('QMYSQL3') # tried with QMYSQL too
db.setHostName(host)
db.setDatabaseName(dbname)
db.setUserName(user)
db.setPassword(password)
db.open()
q = QSqlQuery(db)
q.exec_("SHOW PROCESSLIST")
print q.size() # returns -1!
As I said, it works fine with other queries (SELECT, etc).
Am I doing something wrong? Thank you!
[1]: lists.trolltech.com/qt-interest/2002-09/thread00104-0.html
[2]: www.google.com/codesearch/p?hl=es&sa=N&cd=1&ct=rc#-zNo3rQOo4A/mythtv/libs/libmyth/dbutil.cpp&l=657