yes,i known,but how do i do that? if not commit parent,how to get the parent id?
On 5月20日, 下午6时59分, kindly <kin...@gmail.com> wrote: > Instead of the first commit use flush. You have already committed so > you cant roll back. > > so > > session.begin() > try: > p=parent() > session.add(p) > session.flush() > c=child() > c.p_id=p.id > session.add(c) > session.commit() > except: > session.rollback() > > On May 20, 11:31 am, manman <ne.man...@gmail.com> wrote: > > > session.begin() > > try: > > p=parent() > > session.add(p) > > session.commit() > > c=child() > > c.p_id=p.id > > session.add(c) > > session.commit() > > except: > > session.rollback() > > > the example code is error, when c error, it can't rollback p. please > > tell me how to do,thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@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 -~----------~----~----~----~------~----~------~--~---