[PyQt] Implementing a QSqlDriver in python -> segmentation fault

Phil Thompson phil at riverbankcomputing.com
Sun Aug 9 22:30:52 BST 2009


On Tue, 4 Aug 2009 15:15:35 +0200, Andre Alexander Bell
<pyqt at andre-bell.de>
wrote:
> Hello,
> 
> I often have the problem, that the Qt installation on some computers is
not
> 
> shipped with the mysql plugin. Hence, I can't access a mysql database
from 
> PyQt on such an computer.
> Since I need to have the same compiler, as Qt has been compiled with, to
> build 
> the plugin myself, I thought it would be far easier to implement my own 
> SqlDriver from within python (e.g. with mysql-python).
> Therefore I subclassed QSqlDriver and QSqlResult from PyQt. However, if I
> do 
> so I get a segmentation fault when I run a query on my database
connection.
> I stripped the code down to the most simple case which just simulates a 
> database without data.
> As soon as I run a query (QSqlQuery) on this database the python shell
> crashes 
> with a segmentation fault.
> To figure out why I digged into the qt cpp-source code and followed along
> the 
> QSqlQuery::exec(QString query) method. I followed along the lines and
could
> 
> repeat the calls on my on PySqlResult created with createResult() method.
> If I do everything in QSqlQuery::exec(QString) my self it works. By using

> QSqlQuery it does not. I wonder if it has to do something with the
internal
> 
> assignements done in QSqlQuery::exec:
> 
> *this = QSqlQuery(...)
> 
> Has anybody ever tried to implement a QSqlDriver in python and succeeded?
> Any 
> hint for me?

Should be fixed in tonight's PyQt snapshot.

Phil


More information about the PyQt mailing list