Python flask.ext.mysql is deprecated?(Python flask.ext.mysql 已弃用?)
问题描述
当我运行 from flask.ext.mysql import MySQL
时,我收到警告 Importing flask.ext.mysql is deprecated,改用flask_mysql
.
When I run from flask.ext.mysql import MySQL
I get the warning Importing flask.ext.mysql is deprecated, use flask_mysql instead
.
所以我使用pip install flask_mysql
安装了flask_mysql,安装成功但是当我运行from flask_mysql import MySQL
时我得到错误No module named flask_mysql代码>.在第一个警告中,我也得到
Detected 扩展名为flaskext.mysql,请将其重命名为flask_mysql.旧形式已弃用..format(x=modname), ExtDeprecationWarning
.你能告诉我我应该如何将它重命名为flask_mysql吗?提前致谢.
So I installed flask_mysql using pip install flask_mysql
,installed it successfully but then when I run from flask_mysql import MySQL
I get the error No module named flask_mysql
. In the first warning I also get Detected extension named flaskext.mysql, please rename it to flask_mysql. The old form is deprecated.
.format(x=modname), ExtDeprecationWarning
. Could you please tell me how exactly should I rename it to flask_mysql?
Thanks in advance.
推荐答案
flask.ext.
是一种已弃用的模式,广泛用于较旧的扩展和教程中.警告告诉你用直接导入替换它,它猜测是 flask_mysql
.然而,Flask-MySQL 正在使用一种更加过时的模式,flaskext.
.除了说服维护者发布修复它的新版本之外,您无能为力.from flaskext.mysql import MySQL
应该可以工作并避免警告,尽管最好将包更新为使用 flask_mysql
代替.
flask.ext.
is a deprecated pattern which was used prevalently in older extensions and tutorials. The warning is telling you to replace it with the direct import, which it guesses to be flask_mysql
. However, Flask-MySQL is using an even more outdated pattern, flaskext.
. There is nothing you can do about that besides convincing the maintainer to release a new version that fixes it. from flaskext.mysql import MySQL
should work and avoid the warning, although preferably the package would be updated to use flask_mysql
instead.
这篇关于Python flask.ext.mysql 已弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Python flask.ext.mysql 已弃用?


基础教程推荐
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带更新的 sqlite CTE 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- 带有WHERE子句的LAG()函数 2022-01-01