0% found this document useful (0 votes)
3 views7 pages

(L9)Programming with Python(Intermediate Level)

This document covers the use of Python with MySQL for database applications, highlighting MySQL as a popular database management system. It outlines the installation of MySQL Server and the MySQL Connector/Python, along with the steps to establish a connection with the server. The general workflow for interacting with a MySQL database using Python is also provided.

Uploaded by

hobohin914
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
3 views7 pages

(L9)Programming with Python(Intermediate Level)

This document covers the use of Python with MySQL for database applications, highlighting MySQL as a popular database management system. It outlines the installation of MySQL Server and the MySQL Connector/Python, along with the steps to establish a connection with the server. The general workflow for interacting with a MySQL database using Python is also provided.

Uploaded by

hobohin914
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 7

Programming with Python

(Intermediate Level)
Lesson-9 Database and Python

Coding ညေကျာင်း by Code Champs Coding School


MySQL Python
Python can be used in database applications.
One of the most popular databases is MySQL.
MySQL is one of the most popular database management systems (DBMSs) on the market
today.
SQL stands for Structured Query Language and is a widely used programming language for
managing relational databases.
You may have heard of the different flavors of SQL-based DBMSs.
The most popular ones include MySQL, PostgreSQL, SQLite, and SQL Server.
All of these databases are compliant with the SQL standards but with varying degrees of
compliance.
Installing MySQL Server and MySQL Connector/Python
You need to set up two things: a MySQL server and a MySQL connector.

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.

MySQL is a server-based database management system.

One server might contain multiple databases.

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:

1. Connect to the MySQL server.


2. Create a new database.
3. Connect to the newly created or an existing database.
4. Execute a SQL query and fetch results.
5. Inform the database if any changes are made to a table.
6. Close the connection to the MySQL server.

You might also like