[PyQt] unable to load the postgre sql drivers in pyqt

Phil Thompson phil at riverbankcomputing.co.uk
Sun Dec 30 11:08:33 GMT 2007


On Sunday 30 December 2007, nishith datta wrote:
> hi all,
>   I have installed python 2.5 , QT 4.3.3 opensource with mingw, and pyqt
> 4.3.1-1 on a winXP machine.

I assume that you mean the binary installer of PyQt.

> I am trying to establish a connection to the 
> postgres SQL 8.2 database on my machine using the pyqt . The code is as
> under :-
>
>   from PyQt4.QtGui import *
> from PyQt4.QtCore import *
> from PyQt4 import QtSql
>
>   db = QtSql.QSqlDatabase.addDatabase("QPSQL")
> db.setDatabaseName("test")
> db.setUserName("root")
> db.setPassword("mypass")
> name = db.open()
> print db.lastError().text()
>
>   I get an error driver not loaded . I can't understand how to have the
> psql driver loaded. Can someone help me out.
>   By the using psycopg2 I can easily establish connection and also execute
> queries on the database. thanks in advance.
>   nishith

The PyQt binary includes Qt and does not include Postgres support. You need to 
build PyQt yourself.

Phil


More information about the PyQt mailing list