LinMinquan's Blog

Experience technology to change life

SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.

Environment:Mac OS 10.12.2, Python 2.7.10, SQLAlchemy 1.1.4

在试教程 http://www.jikexueyuan.com/course/1387_2.html?ss=1 时,用到python flask_sqlalchemy (version 1.1.4)时,报一个warning

/Users/xxx/Develop/flasktest-database/venv/lib/python2.7/site-packages/
flask_sqlalchemy/__init__.py:800: 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.')

解决办法是加一行配置,将SQLALCHEMY_TRACK_MODIFICATIONS设为true,如下

app.config['SQLALCHEMY_DATABASE_URI']="mysql://root:password@localhost:3306/jikexueyuan"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True

参考链接:http://www.jianshu.com/p/70c892fab7af


Share