[PyQt] Using PostgreSQL
Matt Newell
newellm at blur.com
Mon Oct 17 17:05:07 BST 2011
Before starting you app set the QT_DEBUG_PLUGINS environment var.
set QT_DEBUG_PLUGINS=1
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
4.6.false]
"""
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.
Matt
On Monday, October 17, 2011 03:06:34 AM paolo at paolodestefani.it wrote:
> Hello
> 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
> loaded".
> This is the code:
>
> app = QCoreApplication(sys.argv)
> db = QSqlDatabase.addDatabase("QPSQL")
> db.setHostName('localhost')
> db.setPort(5432)
> db.setDatabaseName('TestDB')
> db.setUserName('postgres')
> db.setPassword('*****')
> if db.isOpen():
> db.close()
> if not db.open():
> raise Exception("Error opening database:
> {0}".format(db.lastError().text()))
> 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
> found.
> 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
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
More information about the PyQt
mailing list