不推荐使用Python flask.ext.mysql吗? [英] Python flask.ext.mysql is deprecated?
问题描述
当我运行from flask.ext.mysql import MySQL
时,得到警告Importing flask.ext.mysql is deprecated, use flask_mysql instead
.
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 extension named flaskext.mysql, please rename it to flask_mysql. The old form is deprecated.
.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吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!