On Mar 18, 2013, at 4:22 PM, alonn <[email protected]> wrote:
> from the docs:
>
> begin_nested() may be called any number of times, which will issue a new
> SAVEPOINT with a unique identifier for each call. For each begin_nested()
> call, a corresponding rollback() or commit() must be issued.
>
> Lets say I call session.begin_nested() after each successfull add something
> like:
> for myModule in modules;
> session.add(myModule)
> session.begin_nested()
> try:
> session.flush()
> except:
> session.rollback()
> session.merge(myModule)
> session.begin_nested()
> transaction.commit()
>
> my question is would a transaction.commit() suffice to commit all of the
> saved SAVEPOINTS or am I suppose to call a commit on each and everyone of
> them (as implied in the docs)
you call a commit for every nested that you dont roll back. you shouldn't
call begin_nested in your except: there.
the pattern is:
for item in something:
session.begin_nested()
try:
do something
session.commit()
except:
session.rollback()
session.commit()
>
> Thanks for the help
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.