Backend development

Stage 2 · Lesson 9 of 10

Django ORM or SQLAlchemy with Alembic

Relational databases and SQL

comes with its own and system. Change a model, then run python manage.py makemigrations to generate a migration file, and migrate to apply it. With , the usual pair is for models and queries, and Alembic for migrations.

There, alembic revision --autogenerate drafts a script and alembic upgrade head applies it. Either way, commit the migration files and read what they will do. Use sqlmigrate, or Alembic's offline mode, to see the actual SQL.

Common trapa renamed field: Django asks whether you meant a rename, but Alembic autogenerate reads it as a dropped column plus a new one. Applied blindly, that deletes the data.

A question to check yourself, an AI practice session and 1 cheat sheet entry come with the full roadmap. Unlock

Resources for this stage

Start with· follow one of these

Practise

Also worth your time

Mark this stage as not done?