Skip to main content

Flask extension to integrate Alembic migrations

Project description

This Flask extension provides a configurable Alembic migration environment around a Flask-SQLAlchemy database.

Full documentation

Installation

Install releases from PyPI:

pip install Flask-Alembic

Install the latest code from BitBucket:

pip install https://bitbucket.org/davidism/flask-alembic/get/default.tar.gz

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)

# Auto-generate a migration
alembic.revision('making changes')

# Upgrade the database
alembic.upgrade()

# Access the internals
environment_context = alembic.env

Commands are included for Click and Flask-Script:

$ ./manage.py db revision "making changes"
$ ./manage.py db upgrade

Differences from Alembic core

  • Configuration is taken from Flask instead of alembic.ini.

  • The migrations are stored directly in the migrations folder instead of the versions folder.

  • The extension provides the migration environment instead of env.py.

  • Does not (currently) support offline migrations.

Differences from Flask-Migrate

Flask-Migrate is a simple wrapper around the existing Alembic commands. It associates the Flask-SQLAlchemy database with Alembic, and wraps the Alembic commands with Flask-Script. It still requires the standard Alembic file structure, does not integrate with Flask configuration, and does not expose the Alembic internals.

TODO

  • See if db.session can be used rather than establishing new connections.

  • Support multiple databases though Flask-SQLAlchemy’s binds.

  • Support offline migrations.

Project details


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-1.2.tar.gz (14.7 kB view details)

Uploaded Source

Built Distribution

Flask_Alembic-1.2-py2.py3-none-any.whl (9.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Flask-Alembic-1.2.tar.gz.

File metadata

  • Download URL: Flask-Alembic-1.2.tar.gz
  • Upload date:
  • Size: 14.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Flask-Alembic-1.2.tar.gz
Algorithm Hash digest
SHA256 b77fa38c53d1b77cc1edca68acb9fc984bf846a78e3f26678fd8a76bfdeb8b2a
MD5 def5fff503cd212bd7a52a29862655ea
BLAKE2b-256 0925c255f4b192512e15201522057e3e98f240a7d183259113064a41b9fef9c6

See more details on using hashes here.

File details

Details for the file Flask_Alembic-1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_Alembic-1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ffe421eccec03f123a2fce3b9949abe66bb7c6c1b75c4ec6ad2055ca6df94bbd
MD5 07d915aef65499e657351f7820f49a08
BLAKE2b-256 9a071159461fc50c25f8d7b91dbffbcb7a041a9e1e2b4e42ed3e7be37b14c91f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page