Integrate Alembic with Flask.
Project description
Flask-Alembic
Flask-Alembic is a Flask extension that provides a configurable Alembic database migration environment. Supports Flask-SQLAlchemy, Flask-SQLAlchemy-Lite, or plain SQLAlchemy. Supports Alembic's single and multiple database templates.
Pallets Community Ecosystem
[!IMPORTANT]
This project is part of the Pallets Community Ecosystem. Pallets is the open source organization that maintains Flask; Pallets-Eco enables community maintenance of Flask extensions. If you are interested in helping maintain this project, please reach out on the Pallets Discord server.
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.configinstead ofalembic.iniandenv.py. - Engines and model/table metadata are taken from Flask-SQLAlchemy(-Lite) if available, or can be configured manually.
- The migrations are stored directly in the
migrationsfolder instead of theversionsfolder. - Provides the migration environment instead of
env.pyand 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.
- Adds a system for managing independent migration branches and makes it easier to work with named branches.
- Does not (currently) support offline migrations. I don't plan to work on this but am open to patches.
- Does not (currently) support async engines. I don't plan to work on this but am open to patches.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_alembic-3.2.0.tar.gz.
File metadata
- Download URL: flask_alembic-3.2.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d560ad6caecb8829d5903bb41deda66cabf146f8a4f4c08ec06e074f2a11a5d2
|
|
| MD5 |
45075e24388a4b630594357898b8a415
|
|
| BLAKE2b-256 |
69225a8c03885f636f302a903267be03cf8ad367da7540850f3a1a3821cf990d
|
Provenance
The following attestation bundles were made for flask_alembic-3.2.0.tar.gz:
Publisher:
publish.yaml on pallets-eco/flask-alembic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_alembic-3.2.0.tar.gz -
Subject digest:
d560ad6caecb8829d5903bb41deda66cabf146f8a4f4c08ec06e074f2a11a5d2 - Sigstore transparency entry: 703521625
- Sigstore integration time:
-
Permalink:
pallets-eco/flask-alembic@1672c0f8e4c338571ad73ba2918bc80f20e3ec1d -
Branch / Tag:
refs/tags/3.2.0 - Owner: https://github.com/pallets-eco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1672c0f8e4c338571ad73ba2918bc80f20e3ec1d -
Trigger Event:
push
-
Statement type:
File details
Details for the file flask_alembic-3.2.0-py3-none-any.whl.
File metadata
- Download URL: flask_alembic-3.2.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05c118e407a8dfa144591efb034f71c73b4f1654dd2092da442d84051d35845c
|
|
| MD5 |
18caba7d7b2331da123bd07b29844acf
|
|
| BLAKE2b-256 |
7239670fc159b745c13b828057d46b7d7aa334f12f7b28ac77d712ca82295ae1
|
Provenance
The following attestation bundles were made for flask_alembic-3.2.0-py3-none-any.whl:
Publisher:
publish.yaml on pallets-eco/flask-alembic
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_alembic-3.2.0-py3-none-any.whl -
Subject digest:
05c118e407a8dfa144591efb034f71c73b4f1654dd2092da442d84051d35845c - Sigstore transparency entry: 703521656
- Sigstore integration time:
-
Permalink:
pallets-eco/flask-alembic@1672c0f8e4c338571ad73ba2918bc80f20e3ec1d -
Branch / Tag:
refs/tags/3.2.0 - Owner: https://github.com/pallets-eco
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@1672c0f8e4c338571ad73ba2918bc80f20e3ec1d -
Trigger Event:
push
-
Statement type: