Recall & Review
beginner
What is Flask-SQLAlchemy?
Flask-SQLAlchemy is an extension for Flask that adds support for SQLAlchemy, a tool to work with databases easily using Python code instead of raw SQL.
Click to reveal answer
beginner
How do you initialize Flask-SQLAlchemy in a Flask app?
You first create a Flask app, then create a SQLAlchemy object passing the app or later call init_app(app) on it. Example: <br>
app = Flask(__name__)<br>app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///mydb.sqlite3'<br>db = SQLAlchemy(app)Click to reveal answer
beginner
What configuration key sets the database URL in Flask-SQLAlchemy?
The key is
SQLALCHEMY_DATABASE_URI. It tells Flask-SQLAlchemy where your database is and what type it is, like SQLite or PostgreSQL.Click to reveal answer
beginner
Why do you call
db.create_all() in Flask-SQLAlchemy?Calling
db.create_all() creates all the tables in the database based on your model classes. It sets up the database structure you defined.Click to reveal answer
beginner
What is a model in Flask-SQLAlchemy?
A model is a Python class that represents a table in the database. Each attribute in the class is a column in the table.Click to reveal answer
Which configuration key sets the database location in Flask-SQLAlchemy?
✗ Incorrect
The correct key is SQLALCHEMY_DATABASE_URI to specify the database URL.
What does
db.create_all() do in Flask-SQLAlchemy?✗ Incorrect
db.create_all() creates tables in the database based on your model classes.
How do you link SQLAlchemy to your Flask app?
✗ Incorrect
You create the SQLAlchemy object with the Flask app: db = SQLAlchemy(app).
What is a model in Flask-SQLAlchemy?
✗ Incorrect
A model is a Python class that maps to a database table.
Which database type can you use with Flask-SQLAlchemy?
✗ Incorrect
Flask-SQLAlchemy supports many databases like SQLite, MySQL, and PostgreSQL.
Explain how to set up Flask-SQLAlchemy in a new Flask project.
Think about the steps from app creation to database tables.
You got /5 concepts.
Describe what a model is in Flask-SQLAlchemy and why it is important.
Models connect Python code to database tables.
You got /4 concepts.