[PyQt] data widget mapper not committing

simone simozack at yahoo.it
Tue Sep 2 07:41:29 BST 2008


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 



More information about the PyQt mailing list