【发布时间】:2019-08-09 16:31:22
【问题描述】:
在尝试执行以下操作时:
for line in blines:
line.account = get_customer(line.AccountCode)
我在尝试为 line.account 赋值时遇到错误:
DetachedInstanceError: Parent instance <SunLedgerA at 0x16eda4d0> is not bound to a Session; lazy load operation of attribute 'account' cannot proceed
我是不是做错了什么?
【问题讨论】:
-
没有上下文(更多代码),这将很难说。
-
您可以在会话中设置 expire_on_commit=False:stackoverflow.com/a/50272761/1450541
标签: python sqlalchemy