Flask extension to integrate Alembic with Flask-SQLAlchemy.
Project description
Flask-Alembic
Flask-Alembic is a Flask extension that provides a configurable Alembic migration environment around a Flask-SQLAlchemy database.
Installation
Install from PyPI:
$ pip install Flask-Alembic
Basic Usage
You've created a Flask application and some models with Flask-SQLAlchemy. Now start using Flask-Alembic:
from flask_alembic import Alembic
# Intialize the extension
alembic = Alembic()
alembic.init_app(app)
Commands are added to the flask
CLI:
$ flask db --help
$ flask db revision "making changes"
$ flask db upgrade
You can also access Alembic's functionality from Python:
with app.app_context():
# Auto-generate a migration
alembic.revision('making changes')
# Upgrade the database
alembic.upgrade()
# Access the internals
environment_context = alembic.env
Differences from Alembic
- Configuration is taken from
Flask.config
instead ofalembic.ini
andenv.py
. - The migrations are stored directly in the
migrations
folder instead of theversions
folder. - Provides the migration environment instead of
env.py
and exposes Alembic's internal API objects. - Differentiates between CLI commands and Python functions. The functions return revision objects and don't print to stdout.
- Allows operating Alembic at any API level while the app is running, through the exposed objects and functions.
- Does not (currently) support offline migrations. I don't plan to add this but am open to patches.
- Does not (currently) support multiple databases. I plan on adding support for Flask-SQLAlchemy binds and external bases eventually, or am open to patches.
- Adds a system for managing independent migration branches and makes it easier to work with named branches.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flask_alembic-3.0.1.tar.gz
(9.4 kB
view details)
Built Distribution
File details
Details for the file flask_alembic-3.0.1.tar.gz
.
File metadata
- Download URL: flask_alembic-3.0.1.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfae17c7059724b55a1e866079fe94eb5ecf1dfe2137ab8cfdf9254f0416a1db |
|
MD5 | f188bddfe3a3b85d393ab82f8ec92647 |
|
BLAKE2b-256 | 9c471ab59ed7931ca62b202d0b64fd107f324749f647b3b761a264f3c9e3fb0b |
File details
Details for the file flask_alembic-3.0.1-py3-none-any.whl
.
File metadata
- Download URL: flask_alembic-3.0.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb4b852ab5fb3a256e37d8974e6601ff0bb69ae24cad2e37e63981810c23bd8d |
|
MD5 | 5855b08a0e666fa0d19d9f6b5e80e45a |
|
BLAKE2b-256 | 989ac0e6535ba5ee14bdab311e134f948f572b9e621cad0e7aceebd78048c667 |