[PyQt] Using PostgreSQL

paolo at paolodestefani.it paolo at paolodestefani.it
Mon Oct 17 20:01:27 BST 2011


Finally i understand what's happening...

First the problem is not MSVCR90.DLL related. I cheked the other sql
plugin libraries with dependency walker and i found that for all i've got
the missing library log but at leat psqlodbc4.dll works so that is not the
problem.
The problem was related to libeay32.dll. Pyqt brings with it this library
and put it in 
c:\Program Files\Python32\Lib\site-packages\PyQt4\
but in my computer, that i use for work, i have installed Business Object
Crystal Report too that brings with it the same library but in a different
version and put it in
c:\Windows\System32\
So when i run my application qt loads the library from windows\system32
and the sql plugin not work.

The quick fix was to rename the library in \windows\system32 in .old, and
now everything works very well

Thank you for the help and sorry for my poor english...

On Mon, 17 Oct 2011 09:05:07 -0700, Matt Newell <newellm at blur.com> wrote:
> 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