Key Concepts

Review core concepts you need to learn to master this subject

SQL and Relational Databases

Relational databases are the primary means of storage for structured data. They organize data into tables that each contain data related to one another.

We commonly use SQL, which stands for Structured Query Language, to query and play around with relational databases. This programming language is designed to manage data stored in relational databases.

We can visualize a relational database in the image of tables below.

Querying SQLite Databases with Python
Lesson 1 of 1
  1. 1
    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,…
  2. 2
    Now that you understand a little about SQL and relational databases, let’s discuss SQLite. SQLite is a lightweight disk-based database, meaning we store data on a hard drive or another type of loca…
  3. 3
    Once we have sqlite3 imported, we will need to connect to a database. We can connect to a new or pre-existing database with the sqlite3.connect() API. Remember that an *Application Programmable Int…
  4. 4
    Nice work! Now that we have connected to the titanic.db database, we can execute SQL commands using the cursor object. To start a SQL command (also known as a SQL statement), we must attach the…
  5. 5
    Great job! Now that you can CREATE a SQLite data table and INSERT a single row, let’s insert multiple rows of data with the .executemany() method. In the example below, an object new_students c…
  6. 6
    Now that you know how to create a SQLite table, you’re ready to retrieve existing data. As mentioned earlier, Python is excellent at analyzing, visualizing, manipulating, and testing data. For this…
  7. 7
    Like we used the fetch methods, we can also use a for loop to retrieve data. The following code will iterate through each row in the students table and print each row where the Grade field is ‘Pass…
  8. 8
    Nice job! We have learned how to create, insert, edit, and pull specific data from a SQLite database. However, we need to learn one of the most important methods! If we create or edit a data table …
  9. 9
    Congratulations! You have completed your journey through database operations with Python. Let’s reflect on everything we have learned in this lesson: * SQL, which stands for Structured Query Langu…

What you'll create

Portfolio projects that showcase your new skills

Pro Logo

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory

Pro Logo