Python SQLALCHEMY_TRACK_修改会增加大量开销,并且在将来默认情况下将被禁用。将其设置为True以抑制此警告
我的烧瓶程序中出现上述错误。我正在Pycharm编辑器中使用Flask SQLALCHEMY-2.4.1。 请帮忙解决这个问题。我在这上面浪费了很多时间Python SQLALCHEMY_TRACK_修改会增加大量开销,并且在将来默认情况下将被禁用。将其设置为True以抑制此警告,python,flask,flask-sqlalchemy,Python,Flask,Flask Sqlalchemy,我的烧瓶程序中出现上述错误。我正在Pycharm编辑器中使用Flask SQLALCHEMY-2.4.1。 请帮忙解决这个问题。我在这上面浪费了很多时间 UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning. warnings.war
UserWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.
warnings.warn('SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True to suppress this warning.')
* Serving Flask app "app" (lazy loading)
* Environment: production
WARNING: Do not use the development server in a production environment.
Use a production WSGI server instead.
* Debug mode: off
这是一个警告,意味着将来代码可能会被破坏 请养成阅读错误信息的习惯
SQLALCHEMY\u TRACK\u MODIFICATIONS
可以设置为False,错误将消失
第二个警告基本上是关于使用独立于内置flask web服务器的web服务器
为了缓解这一问题,您需要使用生产级web服务器,如gunicorn或Apache web服务器,您需要:
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
将其放在SQLAlchemy()调用之前。您可以使用相应的烧瓶对象名称更改app