[PyQt] data widget mapper not committing

Scott Frankel frankel at circlesfx.com
Tue Sep 2 16:36:37 BST 2008


Thanks for the example!

Oddly, lastError() returns "OK!" when my database does not accept the  
commit.  Then if I change the QSqlTableModel from OnManualSubmit to  
OnFieldChange, lastError returns "ERROR", but the committed data is  
written back to the db!  Weird.

I'll dig through the pg list archives for any references to this  
problem.

Thanks!
Scott




On Sep 1, 2008, at 11:41 PM, simone wrote:

> Scott Frankel ha scritto:
>
>> Am I missing something obvious?  I've tried to peek inside using  
>> queryModel.lastError(), but it's returning a memory address.  Not  
>> sure how to get a string from this method.
>> I hope someone on the list can help shed light on this problem.
>
> I don't know what's happen (it seems an issue with the database) but  
> if you want to catch the error when committing, you have to know  
> that the function mapper.submit() return true if the operation is  
> ok, or false otherwise. So, to catch an exception:
>
> if not mapper.submit():
>    # using the .text() function return the error as string
>    print "Error on committing: %s" % (model.lastError().text())
> else:
>    print "Everything is ok!"
>
> In some cases, for example if you delete some records, you need to  
> use the model.submit() function instead.
>
> --
> Simone
>
>
> Chiacchiera con i tuoi amici in tempo reale! http://it.yahoo.com/mail_it/foot/*http://it.messenger.yahoo.com
>

Scott Frankel
As seen on TV
President/VFX Supervisor
Circle-S Studios
510-339-7477 (o)
510-332-2990 (c)







More information about the PyQt mailing list