While working with Python we need to work with databases, they may be of different types like MySQL, SQLite, NoSQL, etc. In this article, we will be looking forward to how to connect MySQL databases using MySQL Connector/Python.
MySQL Connector module of Python is used to connect MySQL databases with the Python programs, it does that using the Python Database API Specification v2.0 (PEP 249). It uses the Python standard library and has no dependencies.
Connecting to the Database
In the following example we will be connecting to MySQL database using
Also for the same, we can use
connection.MySQLConnection() class instead of
Another way is to pass the dictionary in the connect() function using ‘**’ operator:
- Python MySQL - Create Database
- Create MySQL Database Login Page in Python using Tkinter
- Matplotlib.pyplot.connect() in Python
- Python MySQL - Join
- Python MySQL - Where Clause
- MySQL-Connector-Python module in Python
- Python MySQL - Select Query
- Python MySQL - Limit Clause
- Python MySQL - Order By Clause
- Python: MySQL Create Table
- Python MySQL - Delete Query
- Python MySQL - Update Query
- Python MySQL - Insert into Table
- Python MySQL - Drop Table
- How to install MySQL connector package in Python?
- Connect new point to the previous point on a image with a straight line in Opencv-Python
- Oracle Database Connection in Python
- Python | Database management in PostgreSQL
- Python - Database Manager (dbm) package
- Create a database in MongoDB using Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.