This tutorial series shows you how to use MySQL Connector/Python to access MySQL databases from Python programs.
What you’ll learn:
- Connect to MySQL server from a Python program
- Insert, Select, Update, and Delete data in the database in Python.
- Call MySQL stored procedures from Python
- Writing / Reading BLOB data in MySQL database from Python.
Prerequisites
- Python Programming
- Basic MySQL
- MySQL stored procedures
Please note that all tutorials in this section are based on Python 3. If you’re looking to learn Python programming or refresh your Python knowledge quickly, you can check out the Python tutorial.
Section 1. Getting Started with MySQL Connector/Python
- Getting Started with MySQL Python Connector – Help you get started with MySQL Connector/Python by introducing the features of the MySQL Python connector and guiding you through the installation process on your system.
- Connecting to a MySQL Database in Python – Show you how to use the connect() function and MySQLConnection object to establish a connection to a MySQL database.
Section 2. Performing Basic Operations (CRUD)
This section shows you how to perform basic operations, including querying data, inserting data, updating data, and deleting data.
- Querying Data from a Table in Python – Show you how to query data in a MySQL database in Python using Python/Connector API, including functions like
fetchone
,fetchmany
, andfetchall
. - Inserting Data Into a Table – Learn how to insert data into a table using MySQL Connector/Python API.
- Updating Data in a Table – Walk you through the steps required to update data in database tables using MySQL Connector/Python API.
- Deleting Data from a Table – Guide you on how to delete data in MySQL database using Python.
Section 3. Stored Procedures
This section shows how to effectively work with MySQL store procedures in Python
- Calling Stored Procedures in Python – Show you how to call MySQL stored procedures in Python using MySQL Connector/Python API.
Section 4. Working with BLOB
This section covers working with BLOB data, enabling you to store large binary objects in the MySQL database. You’ll learn how to save BLOB data into the database, retrieve it, and save the data as a file.
- Retrieving & Updating BLOB in MySQL Database – Show you how to work with MySQL BLOB data in Python, providing examples of updating and reading BLOB data.