Learn
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 withquery.get(id)
. - retrieve related objects by using the attributes instantiated with
db.relationship()
in your model (Reader.query.get(123).reviews.all()
). - use
filter
andfilter_by
to 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,
db.session.delete(Reader.query.get(753))
). - 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!
Sign up to start coding
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.