MySQL With Python With Few Basic CRUD Operations

2020-03-26 Uttkarsh Kabde

MYSQL with Python

Hello Programmers, today we are going to see database connection and programming through python. Before getting started let’s take a look on what is MYSQL Database.


MySQL Database (History)

So now we know what is MySQL Database and how it used in corporate world. Now we are going to use MySQL database Queries using python. Here we are going to execute simple and basic queries. For this we need following libraries.


We can install this library by simply executing pip command as given below

pip3 install mysql

This command will install mysql and its requirements automatically. After installing this library we need one more library i.e. mysql connector to connector mysql with python. To do so we are going to install


we are going to install this library with the same way as we install other libraries i.e.

pip3 install mysql-connector

Now This command will install mysql-connector and its requirements automatically. After installation command prompt will message that libraries are installed successfully.

To check weather its working or not simply open python IDLE or in command prompt enter python command and enter following code to check installations.




After that we are going to perform few basic CRUD that is Create and Delete  operations on database. So here we go

Create a Database:


Here as a example we have created a sample database named firstdb which is shown in above list of databases.

Delete a database:

Note that following operation will delete the database and its components permanently so use this command wisely. To delete perticular database we are going to use DROP command which will delete all the rows and columns from database and also delete the provided database.

DROP command to delete the database

As shown in above list we have deleted our sample database i.e. firstdb that we have created earlier.

So here we have learned how to connect mysql with python and how to execute different mysql queries like createing and deleting database. Shortly we will try to write more on performing different operations on mysql with python. Subscribe to our newletter to get updated with our new posts and dont forget to share it with your programmer friends. If you face any problem regarding this post feel free to comment below. We will try to solve your problem ASAP

Happy coding...

About author

Card image cap
Uttkarsh Kabde

Currently I am Persuing Mtech in IT at Shri Guru Gobind Singh Institute of Engineering and Technology, Nanded!

-Web App Developer


Scroll to Top