[sqlalchemy] Re: how to transaction like this

2009-05-21 Thread manman
thanks very much! On 5月20日, 下午9时03分, Werner F. Bruhin werner.bru...@free.fr wrote: Hi, manman wrote: yes,i known,but how do i do that? if not commit parent,how to get the parent id? flush should be enough, but I think you could also do: assuming you have a relation parent

[sqlalchemy] Re: how to transaction like this

2009-05-20 Thread kindly
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,

[sqlalchemy] Re: how to transaction like this

2009-05-20 Thread manman
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)

[sqlalchemy] Re: how to transaction like this

2009-05-20 Thread Werner F. Bruhin
Hi, manman wrote: yes,i known,but how do i do that? if not commit parent,how to get the parent id? flush should be enough, but I think you could also do: assuming you have a relation parent c.parent.append(p) or the other way round p.children.append(c) Werner