Muscles SQL (deprecated)
Deprecated package:
muscles-sqlhas been superseded bymuscles-data-sqlon PyPI (GitHub repository). Use the successor for new projects. This repository documents the legacymuscles-sqldistribution.
Muscles SQL is a data layer package for SQL databases:
- model-to-table mapping
- engine and session management
- repository CRUD and advanced query API (filters/operators/joins/aggregates)
- transactions and Unit of Work (nested/savepoint/retry helpers)
- migrations v2 commands (Alembic-compatible lazy-load)
- inspect/doctor support with machine-readable diagnostics
Related Repositories
muscles- core schemas, actions, DI and canonical documentation.muscles-documents- document metadata/state can use SQL persistence in applications.muscles-ai- AI/RAG flows can use SQL-backed application state without making SQL generic storage.muscles-otel- observability hooks around SQL-backed flows.muscles-benchmarks- SQL transaction and mapping regression checks.
Quickstart
python -m venv .venv
source .venv/bin/activate
pip install muscles-sql
For local development with the test dependencies:
pip install -e ".[dev]"
pytest -q
muscles-sql doctor --url sqlite:///./app.db
Named SQL Connections
muscles-sql can manage multiple SQL connections without becoming a generic
storage registry. The registry is SQL-only: it owns SQL connection configs,
lazy SQLAlchemy EngineManager instances, sessions, inspect and doctor reports.
from muscles_sql import SqlConnectionConfig, SqlConnectionRegistry
registry = SqlConnectionRegistry(
[
SqlConnectionConfig(name="default", url="sqlite:///./app.db"),
SqlConnectionConfig(name="analytics", url="sqlite:///./analytics.db", role="read"),
]
)
session = registry.session("analytics")
report = registry.inspect("analytics")
CLI diagnostics can read a JSON config:
{
"connections": {
"default": "sqlite:///./app.db",
"analytics": {"url": "sqlite:///./analytics.db", "role": "read"}
}
}
muscles-sql inspect --config sql-connections.json --connection analytics
muscles-sql doctor --config sql-connections.json --all
Diagnostic output uses safe URLs and does not print passwords from DSNs.
Advanced Query Example
from sqlalchemy import func
from muscles_sql import FilterClause, JoinClause, QuerySpec, SqlRepository
spec = QuerySpec(
filters=[FilterClause("status", "eq", "active")],
joins=[JoinClause(table=orders, on=users.c.id == orders.c.user_id)],
select_columns=[users.c.id, func.count(orders.c.id).label("orders_total")],
group_by=[users.c.id],
order_by=[users.c.id.asc()],
)
rows = SqlRepository(session, users).aggregate(spec)
Metadata
Release files for muscles-sql 1.0.3
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 |
|---|---|---|---|---|
| muscles_sql-1.0.3.tar.gz | 17.1 kB | With provenance | Details for muscles_sql-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| muscles_sql-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for muscles_sql-1.0.3-py3-none-any.whl |
Total release size: 31.2 kB
Release files / muscles_sql-1.0.3.tar.gz
| Download URL | muscles_sql-1.0.3.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b2f0c56362d4c3d1a7cea1a470d8e70d4e8ecffb87261d8f67883ebf697b141e
|
|
BLAKE2b-256 checksum How to use checksums |
fea35d64fe8370ef29a9fe3e3f427d87e9e35736e97512e266f6be46912698d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logRelease files / muscles_sql-1.0.3-py3-none-any.whl
| Download URL | muscles_sql-1.0.3-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
dd57adb4da69bf6fb78a141a5d4066ae7562aea798936fe63fefe7b1b442faca
|
|
BLAKE2b-256 checksum How to use checksums |
20688d0f96492512a86cdf45f1ab67c7aa2f4b75ab08bf28098973be25bb7ebe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logSecurity for muscles-sql 1.0.3
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for muscles_sql-1.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 4, 2026.
Transparency logA 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.