Complete the code to fetch all users from the database using Flask-SQLAlchemy.
users = User.query.[1]()The all() method fetches all records from the query.
Complete the code to filter users with age greater than 30.
users = User.query.filter(User.age [1] 30).all()
== filters only users exactly 30 years old.<= includes users 30 or younger.The > operator filters users older than 30.
Fix the error in the query to get the first user with name 'Alice'.
user = User.query.filter_by(name=[1]).first()String values must be quoted in Python queries. Use single or double quotes.
Fill both blanks to optimize the query by selecting only 'id' and 'name' columns.
users = db.session.query(User.[1], User.[2]).all()
Selecting only needed columns reduces data load and speeds up queries.
Fill all three blanks to create a query that orders users by age descending and limits to 5 results.
users = User.query.order_by(User.[1].[2]()).[3](5).all()
Ordering by age descending uses desc(), and limit(5) restricts results to 5.
