Environment Setup For Environment Setupython Mysql
Environment Setup For Environment Setupython Mysql
To build the real world applications, connecting with the databases is the necessity for the
programming languages. However, python allows us to connect our application to the databases
like MySQL, SQLite, MongoDB, and many others.
In this section of the tutorial, we will discuss Python - MySQL connectivity, and we will perform
the database operations in python. We will also cover 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 not a built-in module that comes with the python installation. We need to
install it to get it working.
1. > python -m pip install mysql-connector
https://files.pythonhosted.org/packages/8f/6d/fb8ebcbbaee68b172ce3dfd08c7b8660d09f91d8d54
11298bcacbd309f96/mysql-connector-python-8.0.13.tar.gz to download the source code.
3. Open the terminal (CMD for windows) and change the present working directory to the source
code directory.
1. $ cd mysql-connector-python-8.0.13/
4. Run the file named setup.py with python (python3 in case you have also installed python 2)
with the parameter build.
1. $ python setup.py build
1. $ python setup.py install
This will take a bit of time to install mysql-connector for python. We can verify the installation
once the process gets over by importing mysql-connector on the python shell.