
▲ 0 r/flask
I built a Django-style query manager for SQLAlchemy — useful for Flask apps?
I built sqlalchemy-query-manager, a small package that adds Django-style query ergonomics on top of regular SQLAlchemy models.
I wanted this for backend apps where I kept writing the same filtering, relationship lookup, eager loading, and CRUD boilerplate.
Example:
items = (
Item.query_manager
.where(
Q(is_valid=True) | Q(number__gt=100),
group__is_active=True,
)
.select_related("group")
.order_by("-number")
.limit(20)
.all()
)
What I tried to keep:
- regular SQLAlchemy models underneath
- no replacement for SQLAlchemy
- readable app-level queries
- inspectable SQL
Main features:
Qobjects- Django-style
__lookups - relationship filters
select_related/prefetch_related- CRUD helpers
- aggregates
- raw SQL helpers
- SQL query preview
- sync and async support
Source code: https://github.com/ViAchKoN/sqlalchemy-query-manager
Question: would this be useful in your cases?
Any feedback or criticism would be appreciated.
u/IaMaPPle111 — 13 hours ago