Python MySQL

Python MySQL

Hello, friends let’s connect our web application to our MySQL database to do that first we need to download the MySQL connector so let’s download it .

python -m pip install mysql-connector-python

Test MySQL Connector

import mysql.connector

If the above code was executed with no errors, “MySQL Connector” is installed and ready to be used.

Connection

import mysql.connector

mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword"
)

print(mydb)

Leave a Reply