MySQL is a Relational Database Management System (RDBMS) whereas the structured Query Language (SQL) is the language used for handling the RDBMS using commands i.e Creating, Inserting, Updating and Deleting the data from the databases. SQL commands are case insensitive i.e CREATE and create signify the same command.
In this article, we will be discussing the MySQL Connector module of Python, how to install this module and a piece of code on how to connect this with the MySQL database. For any application, it is very important to store the database on a server for easy data access.
What is MYSQL Connector/Python?
MySQL Connector/Python enables Python programs to access MySQL databases, using an API that is compliant with the Python Database API Specification v2.0 (PEP 249). It is written in pure Python and does not have any dependencies except for the Python Standard Library.
There are various versions of MySQL Connector/Python available:
|Connector/Python Version||MySQL Server Versions||Python Versions|
|8.0||8.0, 5.7, 5.6, 5.5||3.8, 3.7, 3.6, 3.5, 3.4, 2.7|
|2.2 (continues as 8.0)||5.7, 5.6, 5.5||3.5, 3.4, 2.7|
|2.1||5.7, 5.6, 5.5||3.5, 3.4, 2.7, 2.6|
|2.0||5.7, 5.6, 5.5||3.5, 3.4, 2.7, 2.6|
|1.2||5.7, 5.6, 5.5 (5.1, 5.0, 4.1)||3.4, 3.3, 3.2, 3.1, 2.7, 2.6|
This module does not come built-in with Python. To install it type the below command in the terminal.
pip install mysql-connector-python
If any issue is there while installing, one can explicitly specify the module version as follows:
pip install mysql-connector-python==8.0.17
Also, to uninstall current MySQL Connector/Python, you use the following command:
pip uninstall mysql-connector-python
Verifying MySQL Connector/Python installation
After installing the MySQL Python connector, we need to test it to make sure that it is working correctly and we are able to connect to the MySQL database server without any issues.
To verify the installation, we can use the following steps:
- Open Python command line
- Type the following code
If you see the following output, it means that you have been successfully installing the MySQL Connector/Python on your system.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.
- twitter-text-python (ttp) module - Python
- Import module in Python
- OS Module in Python with Examples
- struct module in Python
- Secrets | Python module to Generate secure random numbers
- Python | Writing to an excel file using openpyxl module
- Count frequencies of all elements in array in Python using collections module
- Stack and Queue in Python using queue Module
- Testing in Python using doctest module
- Python | ASCII art using pyfiglet module
- Python | Adjusting rows and columns of an excel file using openpyxl module
- Python | Plotting charts in excel sheet using openpyxl module | Set - 1
- Python | Plotting charts in excel sheet using openpyxl module | Set – 2
- Python | Plotting charts in excel sheet using openpyxl module | Set 3
- Python | Create and write on excel file using xlsxwriter module
- spwd module in Python
- Pygorithm module in Python
- Python | Plotting Area charts in excel sheet using XlsxWriter module
- Python | Getting started with SymPy module
- Python | Plotting bar charts in excel sheet using XlsxWriter module
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.