Split Alembic migrations into per-revision SQL files for linting with Squawk.
Project description
Split Alembic Migrations into Per-Revision SQL Files
alembic-squawk runs Alembic in offline (SQL) mode and splits the output into one .sql file per migration revision. The primary use case is feeding those files to Squawk so lint failures point to a specific migration rather than a monolithic dump.
Features
- Strips the outer
BEGIN/COMMITAlembic wraps the full dump in, so each file contains only its own migration SQL. Pass--assume-in-transactionto Squawk when linting. - Maps each revision back to its source
.pyfile to preserve the original filename in output. - Reads
# -- squawk-ignore-file <rule>Python comments from migration files and prepends them as SQL directives in the generated output, so you can attach Squawk ignores without embedding raw SQL comments in Python source. - Supports filtering by revision range or creation date to narrow linting to recently added migrations.
Installation
uv add alembic-squawk
Usage
Run from your project root (where alembic.ini lives):
alembic-squawk --out-dir /tmp/alembic_sql
The output directory is wiped and recreated on every run.
Options
--out-dir(required): Directory to write SQL files into.--revisions: Alembic revision range. Defaults tobase:head. Accepts any valid range, e.g.origin/main@HEAD:headto dump only migrations not yet on main.--created-after YYYY-MM-DD: Skip migrations created before this date.--lint-preamble: Also write the Alembic preamble (boilerplateSETstatements) to000_preamble.sql. Skipped by default.--verbose: Print the Alembic command and any stderr output.
Each file is named after its migration source file, e.g. 2026_03_16_d4b9da2f705c_add_users.sql.
Example
iloveitaly/python-starter-template is a full Python app with a working integration of alembic-squawk.
MIT License
This project was created from iloveitaly/python-package-template
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 alembic_squawk-0.1.0.tar.gz.
File metadata
- Download URL: alembic_squawk-0.1.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59748a9700e364e2a2211051c6302812a1e1071caaac0c297dc4de2f3c6c68ca
|
|
| MD5 |
ed2f45e649b236b64a9acf520699914c
|
|
| BLAKE2b-256 |
de03e01ef79a5c0e335469337849f85601160f2fc928bdac2ce6796b24e27c9d
|
File details
Details for the file alembic_squawk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: alembic_squawk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.14 {"installer":{"name":"uv","version":"0.11.14","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbddcb430343d1c029c3173f58a44c0d4cf99609e4eb191fb0af4848eca87470
|
|
| MD5 |
f3cae5134d5406cc126a01c8e8b3fc57
|
|
| BLAKE2b-256 |
0565c1854d3e82135fa9a727cf69a51efc6d74b3885f719a6c57f143a7e84468
|