youtube-transcript.ai

Асинхронная SQLAlchemy 2.0 | alembic миграции | Отношения между таблицами | Не FastAPI | Видео 3

Watch with subtitles, summary & AI chat
Add the free Subkun extension — works directly on YouTube.
  • Watch
  • Subtitles
  • Summary
  • Ask AI
Try free →

Developers working with Python, SQLAlchemy, and asynchronous programming who need to manage database schema changes.

TL;DR

This video demonstrates how to use Alembic for asynchronous SQLAlchemy 2.0 migrations, including setting up Alembic, generating migration scripts, and handling both upgrade and downgrade operations. It focuses on asynchronous database interactions and relationship management between tables.

Key Takeaways

In This Video

  1. 00:00Introduction to Async SQLAlchemy

    This video focuses on asynchronous SQLAlchemy, relationships, and database migrations using Alembic.

  2. 00:11Database Table Creation with Migrations

    Learn about proper table creation using migrations, specifically with Alembic.

  3. 00:30Limitations of Base.metadata.create_all

    Base.metadata.create_all only creates new tables, not modifies existing ones like adding columns.

  4. 01:07Introducing Alembic for Migrations

    Alembic automates database migrations, avoiding manual SQL commands for schema changes.

  5. 01:32Installing and Initializing Alembic

    Install Alembic using Poetry and initialize it to create necessary migration files and folders.

  6. 02:40Alembic Templates for Async and Multi-DB

    Alembic offers templates like 'async' for asynchronous databases and 'multidb' for multiple databases.

  7. 03:50Generating and Managing Migrations

    Generate new migrations with 'alembic revision' and manage 'upgrade' and 'downgrade' functions.

Questions & Answers

Как alembic помогает с базами данных?
Alembic генерирует миграции автоматически, позволяя добавлять или удалять колонки и таблицы, избегая ручного написания SQL команд.
Почему нельзя использовать Base.metadata.create_all для изменений?
Base.metadata.create_all создает только новые таблицы. Он не может добавлять новые поля в существующие таблицы, если они уже созданы.
Как установить alembic?
Для установки alembic с помощью poetry выполните команду 'poetry add alembic'. Alembic также требует SQLAlchemy.
Как инициализировать alembic в проекте?
Инициализируйте alembic командой 'alembic init alembic'. Это создаст необходимые файлы и папки для работы с миграциями.
Как alembic обрабатывает асинхронные операции?
Для асинхронных операций используется шаблон 'async', который создает асинхронную функцию 'run_async_migrations' для выполнения миграций через асинхронный движок.
Как создать новую миграцию в alembic?
Создайте новую миграцию командой 'alembic revision -m "сообщение"', например, 'alembic revision -m "Create account Table"'.

Key Terms

Download or copy the punctuated YouTube transcript (Markdown)

Full Transcript (Bilingual)

Loading transcript…

Source

YouTube video. Original: https://www.youtube.com/watch?v=LKkn-2FId8w
Transcript captured and processed by youtube-transcript.ai on 2026-07-02.