[PyQt] QMYSQL + QSqlQueryModel.
Igor Prischepoff
igor at tyumbit.ru
Thu Sep 24 05:40:53 BST 2009
Hello, my previous post didn't have any asnwers, so I'll try once again:
now I'm cutting my example to bare minimum (without models) it's still
behaves very strange:
My info: winxp, msyql 5.0.45, python 2.6.2, latest precompiled pyqt which
comes with mysql plugin as dll , qt 2009.3
Here is a script:
---------------------
from PyQt4 import QtSql, QtGui
from PyQt4.QtSql import *
import sys
app = QtGui.QApplication(sys.argv)
db = QSqlDatabase.addDatabase("QMYSQL")
db.setHostName('localhost')
db.setDatabaseName('mysql')
db.setUserName('root')
db.setPassword('root')
db.setPort(3306)
for driver in QSqlDatabase.drivers():
print driver
if not db.open():
QMessageBox.warning(None, "Error log", QString("Database Error:
%1").arg(db.lastError().text()))
sys.exit(1)
query = QtSql.QSqlQuery(db)
print 'query result is:', query.exec_("select now()")
while query.next():
print "got something"
if query.lastError().type() !=QtSql.QSqlError.NoError:
err = query.lastError()
print 'databaseText error:',err.databaseText()
print 'text error:',err.text()
db.close()
---------------------
And here is output:
QSQLITE
QMYSQL3
QMYSQL
QODBC3
QODBC
QPSQL7
QPSQL
query result is: True
databaseText error:
text error: QMYSQL3: Unable to fetch data
Couple of questons:
why QMYSQL3 in error? I'm accessing QMYSQL plugin.
why no data from mysql?
qt opensource compiled with mingw. mysql plugin which comes witch pyqt
compiled with MS compiler.
Should I recompile mysql plugin with mingw or with MS compiler? Or it
doesn't matter?
Thanks
---
igor at tyumbit.ru
More information about the PyQt
mailing list