[PyQt] QtSql connection fail where psycopg2 success?

Panupat Chongstitwattana panupatc at gmail.com
Wed Jan 11 09:56:38 GMT 2012


I'm using the same ip address, same user name and same password to make
connection. What could cause QtSqlDatabase to fail connection where
psycopg2 has no problem? Am I missing something? Do both of them connect to
the same port by default? Anyway to view more detail error message of QtSql?

psycopg2


conn = psycopg2.connect("dbname='byrd' host='192.168.1.6' user='xxx'
password='xxx'")
cur = conn.cursor()
cur.execute("SELECT * FROM project")
results = cur.fetchall()
for result in results:
    print result

output -- (1, 'Byrdland_and_king', 'P:\\\\Byrdland_and_king')


QtSql


db = QtSql.QSqlDatabase.addDatabase("QPSQL")
db.setDatabaseName("byrd")
db.setHostName("192.168.1.6")
db.setUserName("xxx")
db.setPassword("xxx")
db.open()

output -- False
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20120111/71ab00c3/attachment-0001.html>


More information about the PyQt mailing list