Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Using Databases in Python Course (How To)

via Treehouse

Overview

When you want to store data from a program, you have two general choices: files or databases. In this course, we're going to explore using a database from within Python by using the excellent ORM Peewee. We'll build a command line diary application that stores our thoughts and notes in a SQLite database, lets us review and delete them, and even has a search feature!

What you'll learn

  • ORMs
  • Peewee
  • OrderedDict

Syllabus

Meet Peewee

One way of interacting with a database from Python is to use the Peewee ORM. An ORM, or Object Relational Mapping, turns database tables into Python objects and vice versa. Let's see how to create tables and manipulate data in them.

Chevron 7 steps
  • Meet Peewee, Our ORM

    1:46

  • ORM

    4 questions

  • Modeling

    6:45

  • Create Table

    4 objectives

  • Creating Databases and Tables

    2 questions

  • Queries Are Your Friend

    9:28

  • First Queries

    4 objectives

Our Diary App

Now that we understand Peewee, let's build the app that we're here to build. We want an application we can run from the command line that we can read, write, and delete entries through.

Chevron 6 steps
  • What We're Going To Do

    3:27

  • Short Review

    4 questions

  • Doing Data Entry

    5:10

  • Initialize Database & Create Tables

    3 objectives

  • Switching It Up

    7:01

  • OrderedDict Practice

    2 objectives

Gettin' CRUD-y With It

It's time to build the real core of our application. Let's capture entries and save them, show them, search them, and delete them!

Chevron 8 steps
  • Add An Entry

    4:04

  • CRUD: Create Function

    1 objective

  • View and Search Entries

    9:11

  • CRUD: Search Function

    1 objective

  • Delete An Entry

    4:43

  • CRUD: Delete Function

    1 objective

  • Clean Up

    4:50

  • Review: Using Databases in Python

    8 questions

  • Extra Credit

    Use textwrap and Blessings to make your application more professional and interesting.

Reviews

Start your review of Using Databases in Python Course (How To)

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.