例如,此代码:
db = SQLAlchemy()
def myfunction(a):
#somechanges in database
if a == 2:
return
db.session.commit()
myfunction(2) # there were some changes here that were not committed neither rolled back
myfunction(4) # Here the changes were committed.
我的问题是,在第二次调用中,第一次更改是否与第二次更改一起提交?在
提前谢谢
如果您阅读the tutorial,您将看到会话具有
dirty
属性:它告诉你什么?在
对
myFunction(4)
调用中执行的更改将覆盖对myFunction(2)
调用中执行的更改。无论是否提交,更新数据都是如此。在对于添加行和列,没有数据重写。在函数调用
myFunction(4)
之前提交不会产生任何影响。在相关问题 更多 >
编程相关推荐