Fetch Rows with query and get
Retrieve all, one, or by primary key.
Reading Starts With query
Every read from your database begins with the model's query attribute. It is your gateway to fetching rows as Python objects. 🔎
rows = User.queryGrab Everything with all
Call all() on a query to load every matching row into a plain Python list you can loop over.
users = User.query.all()
for u in users:
print(u.name)All lessons in this course
- Fetch Rows with query and get
- Filter, Order, and Limit Results
- Define Relationships and Foreign Keys
- Joins and Lazy vs Eager Loading