views:

68

answers:

1

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

+1  A: 

I don't know what is wrong, but in recent versions of MySQL you can work it around using information_schema.processlist:

SELECT * FROM INFORMATION_SCHEMA.PROCESSLIST
Lukáš Lalinský
That was added in 5.1.x, and I need to work at least with 5.0.x, but thank you anyway!
Martín M.