The method of the Python operations database recommended on the web is to call MySQL for Python, and some call it mysqldb,
The reason is that this is written in C, fast.
Use Pip to install third-party libraries under Ubuntu. sudo pip install Mysql-python
But in the Python3, using the original python2.7 MySQLdb has been unable to connect to the MySQL database.
One of the Pymysql has provided a full Python-written MySQL third-party library.
Pymysql is used in almost the same way as MYSQLDB, if you have previously used the MYSQLDB, simply Import MySQLdb
Modify it to import pymysql.
install Pymysql with Pip under Ubuntu. sudo pip3 install pymysql. or sudo pip install pymysql
Website link
Python-pip default is version 2.x, if you want to install Python3 need to install by the following command:
sudo apt-get install Python3-pip
The command to install the Python package is as follows:$ sudo pip3 install PackageName
How to connect to MySQL using Python3