在before_flush事件中添加到SQLAlchemy Session?

时间:2016-01-21 07:52:36

标签: python sqlalchemy

在没有无限循环的before_flush事件中,是否有正确的方法将新对象添加到Session?

示例:

from sqlalchemy import event

@event.listens_for(SomeSessionOrFactory, 'before_flush')
def receive_before_flush(session, flush_context, instances):
    session.add(NEW_OBJECT)

0 个答案:

没有答案