Learn Python – Environment Setup- Basic and advance

To construct the real world applications, connecting with the databases is the necessity for the programming languages. However, python lets in us to connect our software to the databases like MySQL, SQLite, MongoDB, and many others.

In this part of the tutorial, we will talk about Python – MySQL connectivity, and we will perform the database operations in python. We will additionally cowl the Python connectivity with the databases like MongoDB and SQLite later in this tutorial.

Install mysql.connector

To connect the python application with the MySQL database, we must import the mysql.connector module in the program.

The mysql.connector is now not a built-in module that comes with the python installation. We need to deploy it to get it working.

Execute the following command to deploy it the use of pip installer.

>  python -m pip install mysql-connector  

Or follow the following steps.

  1. Click the link:

https://files.pythonhosted.org/packages/8f/6d/fb8ebcbbaee68b172ce3dfd08c7b8660d09f91d8d5411298bcacbd309f96/mysql-connector-python-8.0.13.tar.gz to down load the supply code.

2. Extract the archived file.

3 Open the terminal (CMD for windows) and change the existing working directory to the supply code directory.

$  cd mysql-connector-python-8.0.13/  

four Run the file named setup.py with python (python3 in case you have additionally set up python 2) with the parameter build.

$ python setup.py build  

5. Run the following command to installation the mysql-connector.

$ python setup.py install  

This will take a bit of time to deploy mysql-connector for python. We can confirm the set up as soon as the system receives over by way of importing mysql-connector on the python shell.

Hence, we have efficaciously set up mysql-connector for python on our system.