1 载入sql插件错误
- Problem
sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:mysql.pysql
- Reason
不能载入sql插件:mysql.pysql,其中pysql编辑错误. - Solve
pysql改为pymysql.
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:123456@localhost:3306/knowledge?charset=utf8"
2 SQLALCHEMY配置错误
- Problem
KeyError: 'SQLALCHEMY_TRACK_MODIFICATIONS'
- Reason
未初始化SQLALCHEMY配置,在app.run()的文件中使用了新的app=Flask(name). - Solve
初始化数据库配置,在__init__.py
的配置文件中初始化app=Flask(__name__)
,运行文件中导入app即可,否则不会执行初始化.
[参考文献]
[1]https://www.cnblogs.com/zhangchenglzhao/p/9774004.html