Congratulations! This was maybe a challenging, but hopefully rewarding experience for you.
In this lesson you learned how to:
- query all entries with
query.all(), or fetch an entry based on the value of its primary key with
- retrieve related objects by using the attributes instantiated with
db.relationship()in your model (
filter_byto select database entries based on some criterion (for example,
Book.query.filter(Book.year = 2020).all()).
- filter database entries by analyzing the patterns in their column values (for example,
emails = Reader.query.filter(Reader.email.like('%.%@%')).all()).
- add new entries to a database, or how to rollback in case the transaction had erroneous entries.
- update existing entries in the database (for example,
Reader.query.get(3).email = “[email protected]”).
- remove database entries (for example,
- 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:
Feel free to further explore all the files included in the final demonstration. You did a great job!