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
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,
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)
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