Python MySQL Connector – Tutorial
Python needs a MySQL driver to access the MySQL database.
STEP – 1 Download MySQL connector from https://dev.mysql.com/downloads/connector/python/

2 After Installing the mysql connector, check whether python is working in the command prompt.

STEP – 3 Import mysql, accordingly. If you do not see any error in the command prompt you can proceed ahead.
STEP – 4 CREATE A CONNECTION
Start by creating a connection to the database.
Use the username and password from your MySQL database:
Go to MYSQL workbench to check the user name and password, use the same credentials while creating a database.
Put your root password:


STEP – 5 Download Sublime Text
What is Sublime Text?
Sublime Text is a shareware cross-platform source code editor with a Python application programming interface. It natively supports many programming languages and markup languages, and functions can be added by users with plug ins, typically community-built and maintained under free-software licenses (Tip: Ctrl + B) to get the output
https://www.sublimetext.com/ > Download for Windows

Open Sublime Text and put the following code, If you do not get an error in the output. That means you have successfully established the connection.
STEP – 6 CREATE A DATABASE

Note: Please use your own root password and username to create a database.
STEP – 7 CHECK IF DATABASE EXISTS

STEP – 8 CREATE A TABLE
To create a table in MySQL, use the “CREATE TABLE” statement.
Make sure you define the name of the database when you create the connection

STEP – 9 CHECK IF TABLE EXISTS

STEP – 10 PYTHON MySQL INSERT INTO TABLE
To fill a table in MySQL, use the “INSERT INTO” statement

Python MySQL Connector – Tutorial