sqlfy CLI
Flyway SQL migration parser — schema graph engine, LLM vector chunk builder, and migration analysis toolkit.
Features
- Schema Analysis: Parse Flyway migrations, reconstruct schema state, detect anti-patterns
- Graph Visualization: Export schema as DOT, Mermaid, Excalidraw, Draw.io, interactive HTML
- Natural Language Q&A: RAG-powered schema assistant with Claude integration
- Migration Safety: Validate ordering, detect drift, analyze rollback feasibility, simulate changes
- Developer Tools: SQL linting, dependency analysis, column-level lineage tracking
Requirements
- Python 3.11+
- uv (recommended) or pip
Quick Start
Install uv (if not already installed)
# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
Install sqlfy
# Clone the repo (if not already cloned)
git clone https://github.com/yourorg/sqlfy
cd sqlfy/cli
# Run the install script (installs globally)
./install.sh
# Verify installation
./verify.sh
# Or install manually
uv build
uv pip install dist/sqlfy-*.whl
Development Setup
# Sync dependencies (creates .venv automatically)
uv sync --all-extras --group dev
# Activate the virtual environment
source .venv/bin/activate # macOS/Linux
.venv\Scripts\activate # Windows
# Install in editable mode
uv pip install -e .
Running Tests
# All tests
uv run pytest -v
# Specific test file
uv run pytest tests/test_core.py -v
# With coverage
uv run pytest --cov=sqlfy --cov-report=term-missing
Building
# Build wheel and source distribution
uv build
# Output: dist/sqlfy-VERSION-py3-none-any.whl
# dist/sqlfy-VERSION.tar.gz
Usage
Basic Commands
# Dump schema state as JSON
sqlfy dump migrations/ --format json > schema.json
# Generate LLM vector chunks
sqlfy chunks migrations/ --format json > chunks.json
# Export as Mermaid diagram
sqlfy graph migrations/ --format mermaid > schema.mmd
# Analyze schema for issues
sqlfy insights migrations/
# Health report with score
sqlfy health migrations/
Schema Evolution
# Compare two schema versions
sqlfy diff migrations-v1/ migrations-v2/
# Simulate a change before applying
sqlfy simulate migrations/ --sql "ALTER TABLE users ADD (status VARCHAR2(20));" --diff
# Detect drift between environments
sqlfy drift migrations-prod/ migrations-dev/
# Analyze rollback feasibility
sqlfy rollback-analysis migrations/
Developer Tools
# Validate migration ordering
sqlfy validate migrations/ --fix-numbering
# Analyze dependencies
sqlfy deps migrations/ --critical-path
# Lint SQL files
sqlfy lint migrations/ --min-score 80
# Column-level lineage
sqlfy lineage APP.USERS.EMAIL
Natural Language Q&A
# Set API key
export ANTHROPIC_API_KEY="sk-..."
# Ask a question
sqlfy ask migrations/ "Which tables have no primary key?"
# Interactive chat
sqlfy chat migrations/
Configuration
pyproject.toml
The project is configured via pyproject.toml:
- Dependencies: Core runtime deps (sqlglot, networkx, sqllineage)
- Optional dependencies:
yaml(PyYAML),dev(pytest) - Entry point:
sqlfycommand →sqlfy.main:main
uv.lock
Lockfile for reproducible builds. Regenerate with:
uv sync --upgrade
Project Structure
cli/
├── src/sqlfy/ # Source code
│ ├── commands/ # CLI command handlers (modular)
│ ├── analysis/ # Schema analysis modules
│ ├── domain/ # Core data models
│ ├── output/ # Export and visualization
│ ├── core.py # Schema parsing engine
│ ├── reconstructor.py # Migration reconstruction
│ └── main.py # CLI entry point (302 lines)
├── tests/ # Test suite (655 tests)
├── pyproject.toml # Project metadata and dependencies
├── uv.lock # Lockfile (148KB, 28 packages)
└── README.md # This file
Testing
Tests use pytest with comprehensive coverage:
- 655 passing tests, 6 skipped
- Coverage: Core parsing, reconstruction, analysis, export, CLI commands
- Run time: ~2.5s
Add a new test
- Create
tests/test_myfeature.py - Import the module to test
- Write test functions starting with
test_ - Run:
uv run pytest tests/test_myfeature.py -v
Contributing
- Create a feature branch
- Make changes
- Add tests for new functionality
- Run
uv run pytest -vto verify - Build and test install:
uv build && uv pip install dist/sqlfy-*.whl - Submit PR
License
See LICENSE file in repository root.
Support
- Issues: GitHub Issues
- Docs: See main README in repository root
- Examples:
cli/examples/directory
Metadata
Release files for sqlfy-cli 0.50.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlfy_cli-0.50.2.tar.gz | 292.1 kB | Without provenance | Details for sqlfy_cli-0.50.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlfy_cli-0.50.2-py3-none-any.whl | Python 3 | none | any | Details for sqlfy_cli-0.50.2-py3-none-any.whl |
Total release size: 548.1 kB
Release files / sqlfy_cli-0.50.2.tar.gz
| Download URL | sqlfy_cli-0.50.2.tar.gz |
|---|---|
| Size | 292.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b22139b4d65b3ca2a0b498302849d4f88481a936c2b9d237e6c5510c5901bd74
|
|
BLAKE2b-256 checksum How to use checksums |
db853a9b56eed5d02a188fcc096225a4df76224ea9893593eaa57d6b4e9983f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
|
Release files / sqlfy_cli-0.50.2-py3-none-any.whl
| Download URL | sqlfy_cli-0.50.2-py3-none-any.whl |
|---|---|
| Size | 256.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91b742f17d01ba9afbbe8ac7f28d46b4d91dedde2dc51c34f7e84175dfb0d9bc
|
|
BLAKE2b-256 checksum How to use checksums |
651f84d3571f7b14920433dd7ece1315d3d8f74c55c654fa79f64bc5d1b48ad1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","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}
|
Security for sqlfy-cli 0.50.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.