Learn

Congratulations! This was maybe a challenging, but hopefully rewarding experience for you.

In this lesson you learned how to:

  1. query all entries with query.all(), or fetch an entry based on the value of its primary key with query.get(id).
  2. retrieve related objects by using the attributes instantiated with db.relationship() in your model (Reader.query.get(123).reviews.all()).
  3. use filter and filter_by to select database entries based on some criterion (for example, Book.query.filter(Book.year = 2020).all()).
  4. filter database entries by analyzing the patterns in their column values (for example, emails = Reader.query.filter(Reader.email.like('%.%@%')).all()).
  5. add new entries to a database, or how to rollback in case the transaction had erroneous entries.
  6. update existing entries in the database (for example, Reader.query.get(3).email = “[email protected]).
  7. remove database entries (for example, db.session.delete(Reader.query.get(753))).
  8. combine databases with your web application’s templates (views).

The database that we sequentially built throughout the Flask-SQLAlchemy lessons has the following final schema: schema

Feel free to further explore all the files included in the final demonstration. You did a great job!

Sign up to start coding

By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.
Already have an account?