admin管理员组

文章数量:1531714

报错

报错信息:
D:\python\lib\site-packages\flask_sqlalchemy_init_.py:872: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future. Set it to True or False to suppress this warning.
warnings.warn(FSADeprecationWarning(

翻译后大致意思:SQLALCHEMY_TRACK_MODIFICATIONS增加了显著的开销,将来会默认禁用。将其设置为 True 以抑制此警告

解决方案

方法一

在当前代码中加入配置

app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///test.db"
# 添加配置
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

方法二

修改源文件中的配置,点击报错链接,进入源代码

源代码

将源文件中的None设置成True

# 将None设置成True
if track_modifications is True:
	warnings.warn(FSADeprecationWarning(
    'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
    'will be disabled by default in the future.  Set it to True '
    'or False to suppress this warning.'
    ))

本文标签: 解决方法SQLALCHEMYTRACKMODIFICATIONS