开发者

Why can't I do SHOW PROCESSLIST with QtSql (PyQT)?

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开发者_如何学Python(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


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


I don't know if you already tried this, but what about adding an ';'?

q.exec_("SHOW PROCESSLIST;")

I have never worked with QtSQL but some MySQL API's do have quite strange behavior and I've run into that problem before.

(sry for bumping an old question, it came up when I was searching for a similar issue)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜