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

Andre Alexander Bell pyqt at andre-bell.de
Tue Aug 4 14:15:35 BST 2009


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?

Regards


Andre

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pyqsqldriver.py
Type: text/x-python
Size: 2617 bytes
Desc: not available
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090804/69e03821/pyqsqldriver.py


More information about the PyQt mailing list