Complete the code to import the ORM base class from SQLAlchemy.
from flask_sqlalchemy import [1]
The SQLAlchemy class is the base for ORM in Flask. It helps connect Python classes to database tables.
Complete the code to define a model class for a user table.
class User(db.[1]):
The Model class is the base class for all ORM models in Flask-SQLAlchemy.
Fix the error in the column definition to specify a primary key.
id = db.Column(db.Integer, [1]=True)
The correct keyword argument to mark a column as primary key is primary_key=True.
Fill both blanks to create a query that gets all users with age greater than 18.
adults = User.query.filter(User.age [1] [2]).all()
The filter uses the greater than operator '>' and the value 18 to get adult users.
Fill all three blanks to create a dictionary comprehension that maps usernames to emails for users older than 20.
user_dict = {user.[1]: user.[2] for user in users if user.[3] > 20}The comprehension uses 'username' as key, 'email' as value, and filters users with 'age' greater than 20.