[PyQt] How to communicate with mysql?
Sibylle Koczian
Sibylle.Koczian at t-online.de
Sun Jan 27 10:24:50 GMT 2008
Am Samstag, 26. Januar 2008 19:05:38 schrieb Ryen Lee:
> Hi everybody! I am a newbie for PyQT.Now I am write a simple programm which
> use mysql as its database,but I find it is very diffucult to use the PyQT
> APIs.I write sth like that:
>
> db = QtSql.QSqlDatabase.addDatabase("QMYSQL")
> db.setHostName("127.0.0.1")
> db.setDatabaseName("test")
> db.setUserName("root")
> db.setPassword("123456")
> db.open()
>
> but it just doesn't work. <snip>
Meaning? What does db.open() return, True or False? Does the database "test"
exist? And is Qt configured with MySQL support?
Or did you perhaps call these methods before you had created a QApplication or
a QCoreApplication object? That won't work and the error messages aren't very
helpful for this case.
I can't test your code, because I don't have MySQL installed.
HTH
Sibylle
--
Dr. Sibylle Koczian
More information about the PyQt
mailing list