[PyQt] Using PostgreSQL
newellm at blur.com
Mon Oct 17 17:05:07 BST 2011
Before starting you app set the QT_DEBUG_PLUGINS environment var.
Also in the windows registry Qt caches which plugins are valid. If the
qsqlpsql4.dll wouldn't load once it will not try to load it again even if you
fix dll problems. Go ahead and delete the entire plugin cache part of the
registry each time. You can automate this by creating a .reg file with the
following contents adjusted for Qt version:
Windows Registry Editor Version 5.00
[-HKEY_CURRENT_USER\SOFTWARE\Trolltech\OrganizationDefaults\Qt Plugin Cache
Then you can execute the file with
regedit /s path_to_my.reg
The MSVCR90.dll might not actually be a problem, but you should be able to find
out with the QT_DEBUG_PLUGINS env variable set. You can also profile your app
through depends.exe and see if qsqlpsql4.dll loads okay.
On Monday, October 17, 2011 03:06:34 AM paolo at paolodestefani.it wrote:
> I have a problem using PostgreSQL with pyqt. My pc is a Windows 7 32bit,
> i've installed postgresql 9.1 with odbc drivers BUT i want to use it in
> pyqt with the native driver. I've wrote a small script to test everything
> but this work if i use ODBC, if i use PSQL i get an errore "Driver not
> This is the code:
> app = QCoreApplication(sys.argv)
> db = QSqlDatabase.addDatabase("QPSQL")
> if db.isOpen():
> if not db.open():
> raise Exception("Error opening database:
> query = QSqlQuery()
> query.exec_("select * from test_table;")
> while query.next():
> print(query.value(0), query.value(1) )
> This code return the error "Driver not loaded". If i change only the
> database driver, this line:
> db = QSqlDatabase.addDatabase("QODBC")
> I get the correct output:
> 1 Prova paolo
> 2 Prova Pippo Baudo
> So what's wrong ?
> I've cheked qsqlpsql4.dll with dependecy walker and i get this log:
> Error: At least one required implicit or forwarded dependency was not
> Error: At least one module has an unresolved import due to a missing
> export function in an implicitly dependent module.
> Warning: At least one module has an unresolved import due to a missing
> export function in a delay-load dependent module.
> The missing librery should be MSVCR90.DLL but even if i dowload this file
> from internet i get the same error.
> I've tryed to install Microsoft Visual C++ 2010 runtime (vcredist_x86.exe)
> with no success.
> PyQt mailing list PyQt at riverbankcomputing.com
More information about the PyQt