Bootstrap

Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set

flask 启动时未设置该参数时会报错:

在config中添加设置即可:
1.

SQLALCHEMY_DATABASE_URI = 'mysql://root:[email protected]/数据库名称'
SQLALCHEMY_TRACK_MODIFICATIONS = False
或者:
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:[email protected]/数据库名称'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
如果还是报错,注意看看参数的导入是不是在db创建之前导入的:必须先导入参数,再创建db才有效
    
app.config.from_object(config_model)
db = SQLAlchemy(app)


                
      
;