[PyQt] SQLite commit success, but data isn't modified

David Boddie dboddie at trolltech.com
Fri Nov 7 17:45:10 GMT 2008


On Thu Nov 6 10:48:55 GMT 2008, Alessandro Re wrote:

> I'm trying to using QSqlTableModel on a SQLite database.
> Following the Qt Cached Table Example, I did a simple program (see below):
> pressing a button should commit table's changes to the database.
> But pressing it, the table return to original data, even if the
> submitAll() method return true.

That's strange. It worked for me (after a trivial fix) with a suitably
prepared database. Is the database file writable? Which versions of Qt and
PyQt are you using?

> I'd like to check at low level how Qt talk to SQLite (e.g. the query
> sent), is there a method?

You can get the query used by the model with its query() method:

http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qsqlquerymodel.html#query

There's also a low-level way to get all queries used by Qt, but it would
require you to recompile Qt.

David


More information about the PyQt mailing list