[PyQt] Re: Re: How to communicate with mysql?
diyer2002 at gmail.com
Sun Jan 27 13:24:34 GMT 2008
> > 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
> Thank you for your reply!
I try to fix the problem as you told,but I failed finally.I think PyQt
doesn't support mysql very well,because when I change
db = QtSql.QSqlDatabase.addDatabase("QMYSQL")
db = QtSql.QSqlDatabase.addDatabase("QSQLITE")
it works.So I decide to use mysqldb instead of PyQT's APIs
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt