// the find
litestar-org/advanced-alchemy
A carefully crafted, thoroughly tested, optimized companion library for SQLAlchemy
Advanced Alchemy is a SQLAlchemy companion that adds a repository/service layer, framework integrations (Litestar, FastAPI, Flask, Starlette, Sanic), custom column types, and Alembic tooling on top of core SQLAlchemy. It's the official SQLAlchemy plugin for Litestar but works standalone. Target audience is Python backend developers who want structured data access patterns without reaching for a full ORM framework.
1. The built-in types are genuinely useful and production-grade: encrypted columns with pgcrypto/Fernet, password hashing with Argon2/Passlib/Pwdlib including transparent rehash-on-verify, TOTP with encrypted seed storage, and one-time codes with attempt lockout. These are things most projects roll manually and get wrong. 2. Read/write replica routing with automatic query routing and sticky-primary mode is a real feature — not just connection pool sugar. Most ORMs make you implement this yourself. 3. Test coverage is serious: both unit and integration tests hit real databases (asyncpg, psycopg3, aiosqlite, oracledb, etc.), and SonarCloud quality gates are enforced. 4. UUID6/UUID7 support with graceful fallbacks, NanoID, composite primary keys, and sentinel columns are practical gaps SQLAlchemy core doesn't fill — these save real boilerplate.
1. The dual sync/async codepaths (_async.py / _sync.py, same for service layer) means every change needs to happen twice. The files are clearly mirrored and there's no codegen — this will drift. 2. Feature sprawl: dogpile.cache integration, in-memory repository for testing, file object storage with fsspec/obstore backends, routing makers. It's trying to be the entire SQLAlchemy ecosystem in one package, which makes the dependency surface and maintenance burden significant. Dogpile.cache in particular is old and nearly nobody uses it. 3. The in-memory repository (_sync.py, _async.py under repository/memory/) is marketed as useful for testing but in-memory semantics differ from real DB in subtle ways — FK enforcement, transaction isolation, LIKE behavior. This is the kind of shortcut that causes flaky prod bugs. 4. Despite claiming to support FastAPI, Flask, Starlette, and Sanic equally, the Litestar integration is clearly the primary path — the other integrations have minimal tests and the extension structure is visibly thinner.