flask database connection settings

Database connection settings

File

  • In Flask-SQLAlchemy, the database using the specified URL, and the program must be saved to the database using the Flask configuration objects SQLALCHEMY_DATABASE_URI key
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:[email protected]:3306/test'
  • other settings:
# 动态追踪修改设置,如未设置只会提示警告
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
#查询时会显示原始SQL语句
app.config['SQLALCHEMY_ECHO'] = True
  • MySQL needs to create a configuration used in the project database
$ mysql -uroot -pmysql
$ create database test charset utf8;

Guess you like

Origin blog.csdn.net/qwertyuiopasdfgg/article/details/93337753