FastAPI - using Alembic for database migrations

preview_player
Показать описание
Alembic is a lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python.

Why Alembic?
- It's allows developers to manage the database migrations with ease.
- We can the changes and revert the changes to/from the database.
- Alembic is similar to Active Record Migrations for Ruby on Rails

install "alembic" with pipenv
- run the command pipenv install alembic
- activate the virtual environment with command pipenv shell
- now, run the command alembic init alembic. It will create the configuration files for alembic.

#alembic #sqlalchemy #fastapi #flask
Рекомендации по теме
Комментарии
Автор

Thx for video, it helps me to understand alembic 👍

ZifeRRoT
Автор

00:02 Alembic is a Python-based data migration tool used along with SQL algorithms.

02:15 Creating two tables - product and category

04:32 Changing the database URL and loading database username from environment variables

07:11 Creating a category table with id, name, description, and timestamp columns.

09:52 Using Alembic for database migrations in FastAPI

12:30 Implementing database downgrade using Alembic for FastAPI

14:57 Using Alembic for database migrations in FastAPI

17:05 Using Alembic for database migrations in FastAPI

Crafted by Merlin AI.

aitools
Автор

The use of any ORM tool is to detect the new entries or changes in the table, and do the migrations activities via alembic upgrade command. I feel the way it is been manually done here doesn't seems right.

papunmohanty