On May 27, 2010, at 5:12 PM, Kent wrote: > The docs state "For each begin_nested() call, a corresponding > rollback() or commit() must be issued." > > In PostgreSql, according to my understanding, if there is ever a > database exception, a rollback must be issued. > This means a main reason to issue a SAVEPOINT is as a hedge against an > error. > > As database transactions go, I want this entire thing to be a single > transaction, so now I don't know how to continue... > > For example, > > DBSession.begin_nested() #savepoint > DBSession.add(obj) > try: > DBSession.flush() > except IntegrityError: > DBSession.rollback() > else: > # now what? I do not want to commit, i have much > # more work to do than this which should be part of > # this transaction, but if I don't commit now, > # i need to issue 2 commits later()?? > > Is releasing the savepoint a choice instead of rolling() or commit()?
commit() releases the savepoint, if thats whats going on contextually. It doesnt actually commit the outer transaction if you've last called begin_nested(). your block should be like: session.begin_nested() try: ... session.flush() session.commit() except: session.rollback() -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalch...@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.