We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
参考Four SQLAlchemy Tips,Miguel建议不要在models模块中使用db.session.commit(),而应该在更高层的业务逻辑代码中去使用它(比如视图函数中),理由是可能会出现不符合预期的结果。 想了解下辉哥你对于这个问题的看法是什么,因为目前狼书里相关项目的models模块是包含db.session.commit()的,想问下根据你的经验,这种写法有出现过问题吗?
The text was updated successfully, but these errors were encountered:
查了下,发现SQLAlchemy docs中也提到了这点:https://docs.sqlalchemy.org/en/13/orm/session_basics.html#when-do-i-construct-a-session-when-do-i-commit-it-and-when-do-i-close-it,所以best practice应该是models模块中不使用commit提交会话,转而在更高层的业务逻辑代码中使用。
SQLAlchemy docs
Sorry, something went wrong.
我倒没遇到实际问题,既然文档提到了,我考虑在第二版更新下。谢谢!
No branches or pull requests
参考Four SQLAlchemy Tips,Miguel建议不要在models模块中使用db.session.commit(),而应该在更高层的业务逻辑代码中去使用它(比如视图函数中),理由是可能会出现不符合预期的结果。
想了解下辉哥你对于这个问题的看法是什么,因为目前狼书里相关项目的models模块是包含db.session.commit()的,想问下根据你的经验,这种写法有出现过问题吗?
The text was updated successfully, but these errors were encountered: