Frequently, advanced Python users will find themselves working with APIs or other external applications. In this lesson, we will learn how to work with SQL databases from a Python environment. SQL, which stands for Structured Query Language, is a programming language designed to manage data stored in a relational database. A relational database is a database that organizes information into one or more data tables.

Databases Contain Data Tables

These data tables each contain many fields and records. Below is an image of a data table, where we see:

  • fields: the columns or attributes of the table
  • records: the rows or observations associated with each field

An image of a table with fields and records

The next image is a data table from a SQL relational database. This is a customer data table where the fields are: first_name, last_name, phone_number, email, and address_id.

The Customer Table

This data table originated from the SQL relational database to your right. Notice how this database is organized into data tables, and each data table has many fields. The lines that run between the data tables are to depict how the tables are related. If you hover over one of the lines, you will notice that the data tables share an identical field. When two or more data tables need data on related topics, it may be necessary for them to contain the same field. This is how these tables are related, hence the name relational database.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?