Python2 and Python3 are incompatible, and in Py2, the linked database uses MYSQLDB, but it is not available in Py3.
The solution is that the module used in the PY3 database is Pymysql.
Installing a third-party library in a DOS window uses a PIP installation.
- First go to the Python installation directory and locate and enter the Scripts folder. For example mine is:
< I don't know. Python default installation Just give me the whole place! >
- To use the PIP installation command:
Python3 pip.exe Install Pymysql # I use Python3 because the py2 and py3 coexist in the computer. This distinguishes it!
This completes the installation of MySQL in Python3.
- To test the import package:
Import Pymysql
Import successfully, then you can use it! # I don't know why it's all lowercase when it's imported
Originality is not easy, respect copyright. Reprint Please specify source:http://www.cnblogs.com/xsmile
Install Pymysql in Python3 under Windows system