Concepts 🚀 Project 🧮 Labs
📚 Learn / Databases & SQL

🗃 Databases & SQL

How data survives between requests — tables, rows, sessions, migrations.

5 concepts
1
SQLAlchemy ORM
Map Python classes to DB tables. No raw SQL — just .query(Model).all().
›
2
DB sessions
A session is a unit of work — track changes, commit, rollback. One per request.
›
3
Relationships & joins
ForeignKey + relationship() lets you walk from a User to their Models with no SQL.
›
4
Schema & migrations
init_db() runs CREATE TABLE IF NOT EXISTS on startup. For schema changes, use Alembic.
›
5
Indexes
Speed up WHERE clauses at the cost of slower writes. Add to columns you filter on.
›