python3 connect to the database using a flask appears "ModuleNotFoundError: No module named 'MySQLdb'"

This link: https: //blog.csdn.net/Granery/article/details/89787348

When using MySQL connection python3 appeared 'ModuleNotFoundError: No module named' MySQLdb '' error.
[Solution] Step
Since this module MySQLdb missing, then the installation module package mysqldb --MySQL-python, performed

pip3 install MySQL-python

after being given the lack of running the program ImportError: No module named 'ConfigParser' .

Find out the reasons, this is because MySQL-python does not support A Python 3
python3 mysqlclient module replaces the use of python2 mysqldb module

[1] Solution
installation module mysqlclient

pip3 install mysqlclient

then you can run normal

[2] Solution
installation module pymysql

pip3 install pymysql

modified SQLALCHEMY_DATABASE_URI = 'mysql: // root: [email protected]: 3306 / db_python' is:
SQLALCHEMY_DATABASE_URI = '+ MySQL pymysql: / /root:[email protected]:3306/db_python'

description link: https : //blog.csdn.net/Granery/article/details/89787348

Guess you like

Origin www.cnblogs.com/z3286586/p/11536506.html