How to Use Python with a Database

Eric Chi
11 min readJun 13, 2023
Photo by valentinadragun on Wallpapers.com

Complete source code can be found here: https://github.com/ericjaychi/sample-python-database-connection

One of the most important pieces of any modern-day application is a database. I don’t think anyone will argue that. So this is a kickstart guide on some of the basics when it comes to working with one of the most important pieces of technology in any program.

Table of Contents

  • Step 1: Installing a Database
  • Step 2: Database Concepts
  • Step 3: Installing Python’s MySQL Connector
  • Step 4: Creating a Database
  • Step 5: Creating a Table
  • Step 6: Creating a Row
  • Step 7: Reading Rows
  • Step 8: Updating a Row
  • Step 9: Deleting a Row

Step 1: Installing a Database

Depending on the database, the installation will differ. Luckily the database of choice within this blog, MySQL, has installers for the most popular operating systems.

First go to: https://downloads.mysql.com/archives/community/

Go through the options to pick a version of MySQL that best fits your operating system, the operating system version, and the specific…

--

--

Eric Chi
Eric Chi

Written by Eric Chi

Passion for learning, teaching, and helping others understand the world of software. Currently working @ Apple