[PyQt] no SQL Drivers available (Gentoo-Linux)

Hans-Peter Jansen hpj at urpla.net
Thu Jan 31 20:26:09 GMT 2008

Am Donnerstag, 31. Januar 2008 schrieb Ulf Röttger:
> Hello Phil, hello Mailinglist,
> I have gentoo-linux (quite up to date) with PyQt 4.3.3 and Qt 4.3.3 and
> all with Python 2.4 (that's an Gentoo issue) x86_32 platform.
> Gentoo compiles QtSQL-Drivers as plugins only, so I have on the Qt side
> sqlite and postgresql:
> nergal at kutha /usr/lib/qt4/plugins/sqldrivers $ ls
> libqsqlite.so  libqsqlite2.so  libqsqlpsql.so

All fine.

> This is the last idea I have got:
> that they need to be compiled as:
> -qt-sql-sqlite instead of -plugin-sql-sqlite

Nope. If Qt can use them as plugins, PyQt can do as well!

> but it would mean to manipulate a lot of ebuild-stuff from Gentoo to get
> this to work, which I do hesitate to do, 'cos other software I need rely
> upon a working qt-environment.
> PyQt compiles with QtSQL:
> nergal at kutha /usr/lib/python2.4/site-packages/PyQt4 $ ls
> Qsci.so         QtDesigner.so  QtScript.so  QtXml.so      elementtree    
> uic Qt.so           QtGui.so    >>>   QtSql.so  <<<   __init__.py  
> pyqtconfig.py QtAssistant.so  QtNetwork.so   QtSvg.so     __init__.pyc 
> pyqtconfig.pyc QtCore.so       QtOpenGL.so    QtTest.so    __init__.pyo 
> pyqtconfig.pyo

All is well.

> I can access databases directly from Python or with non-python Qt
> applications, so I assume there is no malfunction to be expected.
> Even the example from PyQt4 does not work:
> nergal at kutha ~/Python/PyQt4/examples/sql $ python
> Python 2.4.4 (#1, Oct 26 2007, 16:35:26)
> [GCC 4.1.2 (Gentoo 4.1.2)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.

Standard beginners error no. 1 applies:

I bet, you forgot to create QApplication object - did you?

> >>> from connection import createConnection
> >>> createConnection()
> QSqlDatabase: QSQLITE driver not loaded
> QSqlDatabase: available drivers:
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "connection.py", line 33, in createConnection
>     QtGui.QMessageBox.critical(None, QtGui.qApp.tr("Cannot open
> database"), RuntimeError: underlying C/C++ object has been deleted


More information about the PyQt mailing list