not really. think a db.commit() as saving a file. 
if you need to have something that does the 3 operations atomically (i.e. 
either all three or none of them) you just commit() after the third one. 
if you instead need to consolidate what op1 does in fear that what op2 
might fail (and you don't want to loose what you did in op1), you commit() 
after op1.
in that case, if op2 for whatever reason fails, results of op1 are stored, 
no matter what.
You need to rollback() ONLY if you specifically want to discard whatever 
happened since the last commit() (which in "saving a file" example would 
translate to "reload the original version").

On Thursday, June 16, 2016 at 7:28:31 PM UTC+2, Pierre wrote:
>
> ok i think i get it :
>
> suppose I have a *scheduled task* that performs 3 successive 
> *insert/update* ops depending on each other like op2 might refer to op1 
> and op3 to op2 then I must do:
>
> op1 = db.tablea.insert_or_update(......)
> db.commit()
> ....some code here raises an exception
> op2 = db.tableb.insert_or_update(......)
> db.commit()
> op3= db.tablec.insert(...)
> db.commit()
>
> is this correct ?
>
> another thing : let's suppose we want the task to do  nothing but  op1 + 
> op2 + op3 (ie performs 3 insert_update or do nothing) what happens if some 
> code in between op1 and op2 raises an exception. Do I need to do a* 
> db.rollback()* in order to cancel op1 ?
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to