[PyQt] query string from table model submitAll

Scott Frankel frankel at circlesfx.com
Fri Aug 20 07:11:42 BST 2010


Hi all,

Is it possible to get the insert &/or update query statement from a  
QSqlRelationalTableModel's submitAll() operation?

I'm looking for a way to get the query string from a table model's  
submitAll() method when a user invokes it to save data back to the  
database.  I've found QSqlQuery.lastQuery() returns a select  
statement, even when the last apparent operation was writing data back  
to the database.  eg:

		modelErr    = self.theModel.submitAll()
		theQuery    = self.theModel.query()
		print "query: ", theQuery.lastQuery()

This yields:

		SELECT "color_id", "name", "description" FROM "color" ORDER BY  
"color"."name" ASC

rather than the data write statement I'm looking for, eg:

		UPDATE color SET name = 'foo'


See the attached sample program for an example, especially line 121 in  
the saveRecord() method.

Thanks in advance for any suggestions,
Scott



-------------- next part --------------
A non-text attachment was scrubbed...
Name: datawidgetMapperTest.002.py
Type: text/x-python-script
Size: 4653 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100819/f747f935/attachment.bin>
-------------- next part --------------



More information about the PyQt mailing list