Solve the problem of error loading MySQL DB module. Encountered during Django project

Solve the problem of error loading MySQL DB module encountered during Django project

Python version 3.9 was used when creating the Django project. The MySQL database was successfully introduced in the process of doing the project, but later the python version was reduced to 3.7, so this error was reported when re running the system

Problem causes and solutions:
the package used by Django to connect to MySQL in Python 3 is pymysql, so the first step is to install pymysql:

pip install pymysql

Installation does not mean that it is OK. It also needs to be installed in the project__ init__. Add the following code to the. Py file:

import pymysql
pymysql.install_as_MySQLdb()


Read More: