[PyQt] Using PostgreSQL
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 listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Using PostgreSQL
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 pa...@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 listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Using PostgreSQL
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 newe...@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 pa...@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 listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Icon on OS X
On Sunday 16 October 2011, 16:27:25 Clément Mairet wrote: On 10/16/2011 05:52 AM, Joseph Yeung wrote: I am trying out my application on OS X Lion 10.7.2 and PyQt4 4.8.4 and it is showing the default Python Launcher Icon. But on Ubuntu it is showing the icon which I specify. Wondering if there is a specific thing I need to do on OSX. Thanks. Joseph I had the same problem (although on older versions of OS X and PyQt) and only managed to have a proper icon and application name by using py2app to generate a full-blown OS X application. If an easier, more direct solution exists, I'm interested too! :) Your apps need to comply to the usual Mac OS X Application folder structure, including a correct Info.plist file, since the finder examines those only. This is inherited from the resource fork drain bammage of Mac OS. Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] setting color of window titlebar or window background
On Sunday 16 October 2011, 21:14:44 Brad Buran wrote: When users of my program run it in test mode, it is not actively saving data. Once in a while, a user forgets that they are in test mode and attempts to run an experiment only to realize that the data wasn't being saved after they're done. Is it possible to change the color of the title bar or background to indicate that it is in test mode? Something like a bright red title bar would be ideal, but I'm ok with anything that I can set to visually indicate the difference between test and data collection mode that's obvious enough to a user. Yes, of course, but the price is high: draw your own and mimic the window manager behavior (move, hide, {min,max}imize, quit..). How about coloring the background of your app, add some text to the title bar or color your icon red? Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] setting color of window titlebar or window background
we use a stylesheet for this purpose, they are rather easy to implement, and you can have one for test, pre-production, production ... http://doc.qt.nokia.com/latest/stylesheet.html On Mon, 2011-10-17 at 22:00 +0200, Hans-Peter Jansen wrote: On Sunday 16 October 2011, 21:14:44 Brad Buran wrote: When users of my program run it in test mode, it is not actively saving data. Once in a while, a user forgets that they are in test mode and attempts to run an experiment only to realize that the data wasn't being saved after they're done. Is it possible to change the color of the title bar or background to indicate that it is in test mode? Something like a bright red title bar would be ideal, but I'm ok with anything that I can set to visually indicate the difference between test and data collection mode that's obvious enough to a user. Yes, of course, but the price is high: draw your own and mimic the window manager behavior (move, hide, {min,max}imize, quit..). How about coloring the background of your app, add some text to the title bar or color your icon red? Pete ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt