Skip to content

Phase 5 - Databases (Flask-SQLAlchemy)

Most real apps need persistent data.

In Flask, the most common approach is:

  • Flask-SQLAlchemy (integration layer)
  • SQLAlchemy (ORM)
  • Flask-Migrate (migrations via Alembic)

You’ll learn

  • What an ORM is and why it matters
  • Setting up Flask-SQLAlchemy
  • Defining models and data types
  • Creating tables with db.create_all()db.create_all() (dev only)
  • CRUD operations (create/read/update/delete)
  • Relationships (one-to-many, many-to-many)
  • Migrations (Flask-Migrate)
  • Raw SQL when you need it

Phase checklist

  1. Introduction to ORMs
  2. Setting up Flask-SQLAlchemy
  3. Configuring Database URI
  4. Creating Database Models
  5. Primary Keys and Column Types
  6. Creating the Database (db.create_all)
  7. CRUD - Create Record
  8. CRUD - Read Record
  9. CRUD - Update Record
  10. CRUD - Delete Record
  11. One-to-Many Relationships
  12. Many-to-Many Relationships
  13. Database Migrations (Flask-Migrate)
  14. Executing Raw SQL

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did