Sunday, May 21, 2023
HomeSoftware EngineeringEasy methods to Set up MySQL Driver in Python

Easy methods to Set up MySQL Driver in Python


To start utilizing MySQL in Python, you’ll want to do the next:

Step 1 – Set up the MySQL Connector

Utilizing pip, we will set up the MySQL Connector bundle:

python -m pip set up mysql-connector-python

Step 2 – Take a look at the MySQL Connector

Create a Python file and import the brand new bundle:

import mysql.connector

Step 3 – Create a Connection to the MySQL Database

Now you possibly can create a connection to your MySQL database.

Create a file referred to as app.py and place the next inside:

import mysql.connector

your_database = mysql.connector.join(
  host = "localhost"
  consumer = "username"
  password = "YoUrPaSsWoRd"
)

print(your_database)

Step 4 – Run the applying

Now run the app.py Python script to see our connection happen:

python app.py
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments