Simple migration command for Flask and Psycopg 3.
Project description
flask-migratepg: Database Migrations for Flask and PostgreSQL with Psycopg
This is a simple migrations tool for Flask and Psycopg 3.
- Install and setup the Flask extension.
- Place SQL migrations under
database/migrations/. - Execute migrations.
Setup in application:
from flask import Flask
from flask_migratepg import MigratePg
import os
app = Flask(__name__)
app.config.from_mapping(
MIGRATIONS_PATH=os.path.abspath('database/migrations'),
PSYCOPG_CONNINFO="dbname=example host=localhost user=example password=secret"
)
MigratePg(app)
Then to run migrations:
flask migrate execute
This will run migrations in alphabetical order and track them in a migrations table.
Migrations are placed under database/migrations/ as either an SQL or Python file
(that is, with an .sql or .py filename extension resepectively.)
An SQL migration will simply be executed.
A Python migration can implement a method migrate(conn). If this method is
present, it will be called. An example of this:
def migrate(conn):
cur = conn.cursor()
# ...
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-migratepg-0.0.5.tar.gz.
File metadata
- Download URL: flask-migratepg-0.0.5.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cf442f16668296693987c1a06a8353dab83db1532dabf6dc3fb74a3b5f6d04a
|
|
| MD5 |
1ccd838308f63ad911df7c951e211ca2
|
|
| BLAKE2b-256 |
cb586cd16c0f58ca8e726bf456bc08b45fcb8eac2a44d76eb734235a01cb9521
|
File details
Details for the file flask_migratepg-0.0.5-py3-none-any.whl.
File metadata
- Download URL: flask_migratepg-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4fe98dc2333111f9b6ffc0ebaa9ca251ff8e24e09bd5872a683357aa89672195
|
|
| MD5 |
d0584b0deff0452fbc6ca072d4a38585
|
|
| BLAKE2b-256 |
791445ce0bb93b81898c121464d950398fe78b0d64f999cd0c8b2489f0bf0f48
|