标签: 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)