模型.py
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key = true, autoincrement=true)
...
视图.py
entry = User()
with transaction.manager:
DBSession.add(entry)
DBSession.flush()
transaction.commit()
pdb.set_trace()
现在当我跑
print user.id
我明白了
DetachedInstanceError: Instance <Userat 0x3ebc310> is not bound to a Session
如果我改变如果从添加到合并它只会给我
none