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.
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.
Execute the following command to install it using pip installer.
Or follow the following steps.
1. Click the link:
2. Extract the archived file.
3. Open the terminal (CMD for windows) and change the present working directory to the source code directory.
4. Run the file named setup.py with python (python3 in case you have also installed python 2) with the parameter build.
5. Run the following command to install the mysql-connector.
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.
Hence, we have successfully installed mysql-connector for python on our system.
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week