Skip to main content

alchemiq

The data layer for async FastAPI microservices: Django-style models, transactional outbox, caching, and ClickHouse - built on SQLAlchemy 2.0.

PyPI version Python License: MIT Docs CI


30-second example

import alchemiq
from alchemiq import Model, Repository
from alchemiq.types import PK, Email

class User(Model):
    id: PK[int]
    name: str
    email: Email

alchemiq.configure("postgresql+asyncpg://user:password@localhost/mydb")
await alchemiq.create_all()

users = Repository(User)
user  = await users.create(name="Ada Lovelace", email="ada@example.com")
found = await users.get(id=user.id)
print(found.name)  # Ada Lovelace

Features

  • Async PostgreSQL and ClickHouse - a single query DSL covers both backends.
  • Django-flavoured models - declare fields with plain type annotations; Q objects, QuerySet chaining, order_by, limit, and offset work exactly as you would expect.
  • Repository + UnitOfWork - full CRUD, bulk operations, cursor/keyset pagination, and aggregations (Count, Sum, Avg, Min, Max) out of the box.
  • Soft-delete and optimistic locking - opt in per model via a Meta class.
  • Signals - async pre/post hooks for create, update, and delete lifecycle events.
  • Serialization - to_dict, to_schema, to_pydantic with field inclusion/exclusion.
  • Outbox + Relay - atomic event capture in the same transaction, published to any broker (RabbitMQ, Kafka, NATS) via TaskIQ or FastStream.
  • FastAPI integration - auto-generated CRUD router, DI-ready repository and UoW providers, Pydantic schema generation, and a /health/ready · /health/live router.
  • FastStream consumer DI - inject sessions, UoW, and repositories into message handlers.
  • Redis caching - per-repository cache with automatic invalidation on write.
  • Migrations - Alembic wrapper for PostgreSQL; a custom engine for ClickHouse.
  • Scaffolding - alchemiq init generates a production-ready layered project skeleton.
  • SQLite dev/test tier - run your app's tests without Docker; PostgreSQL stays the production target.

Installation

pip install "alchemiq[all]"
Extra Installs
email email-validator
phone phonenumbers
argon2 argon2-cffi
bcrypt bcrypt (not in all)
crypto cryptography
outbox taskiq, taskiq-aio-pika
fastapi fastapi
faststream faststream
redis redis
postgres asyncpg (the PostgreSQL driver)
sqlite aiosqlite (the SQLite driver, dev/test tier)
clickhouse clickhouse-connect[async], clickhouse-sqlalchemy
migrations alembic
all all of the above except bcrypt

Documentation

Full guide and API reference: https://alchemiq.readthedocs.io


Links


What's not in v1

alchemiq v1 does not include a visual admin, MySQL support, synchronous mode, multi-database routing, audit logs, geolocation fields, or file-field storage adapters. SQLite is supported as a dev/test tier - see the SQLite guide.

See the What's not in v1 guide for the full list and the reasoning behind each deferral.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alchemiq-0.2.2.tar.gz (452.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alchemiq-0.2.2-py3-none-any.whl (187.6 kB view details)

Uploaded Python 3

File details

Details for the file alchemiq-0.2.2.tar.gz.

File metadata

  • Download URL: alchemiq-0.2.2.tar.gz
  • Upload date:
  • Size: 452.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alchemiq-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2e194bfa53915ecfae92034db6e4ce8c1048ea3a921b26dfcb680f2e56631d3c
MD5 80aa722b3a2228224a21319caa2a2e6c
BLAKE2b-256 3d8a8c310eadd707249a81a9cc8dadd0d4aa8bfb98ef4cd488f0c9e18222dd71

See more details on using hashes here.

Provenance

The following attestation bundles were made for alchemiq-0.2.2.tar.gz:

Publisher: release.yml on TrifoN-off/alchemiq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alchemiq-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: alchemiq-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 187.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for alchemiq-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5cbce6158b0fe776e53a671affee3a94ead9b39d068cf62dc55e8d3276c9313a
MD5 104d5aeacc7f93bdaddc4102b70b8d01
BLAKE2b-256 b6d40aac4a1236fce61be8fed695b29efd42657c2c48fd9074be44a0d61c3960

See more details on using hashes here.

Provenance

The following attestation bundles were made for alchemiq-0.2.2-py3-none-any.whl:

Publisher: release.yml on TrifoN-off/alchemiq

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page