(L9)Programming with Python(Intermediate Level)
(L9)Programming with Python(Intermediate Level)
(Intermediate Level)
Lesson-9 Database and Python
MySQL server will provide all the services required for handling your database.
Once the server is up and running, you can connect your Python application with it
using MySQL Connector/Python.
To interact with a database, you must first establish a connection with the server.
Install MySQL Driver
Python needs a MySQL driver to access the MySQL database.
We will use the driver "MySQL Connector".
We recommend that you use PIP to install "MySQL Connector".
PIP is most likely already installed in your Python environment.
Navigate your command line to the location of PIP, and type the following:
Download and install "MySQL Connector":
C:\Users\Your Name\AppData\..\Scripts>python -m pip install
mysql-connector-python
Establishing a Connection With MySQL Server
The general workflow of a Python program that interacts with a MySQL-based
database is as follows: