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.0.tar.gz (452.0 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.0-py3-none-any.whl (187.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: alchemiq-0.2.0.tar.gz
  • Upload date:
  • Size: 452.0 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.0.tar.gz
Algorithm Hash digest
SHA256 8c2e522285fa44fd10845f174e7176f6d7c58466ce1a6cc5bdfcb0661a784efe
MD5 be16344f1247ff2d03b706f08b39b555
BLAKE2b-256 600eb7ab16c5f2e967834752db03eb3a28bf47f022e752f9b07e1ce91ab19adb

See more details on using hashes here.

Provenance

The following attestation bundles were made for alchemiq-0.2.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: alchemiq-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 187.5 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ea75cb15fe42eb1da083872d66798f0ba5928f165b843e8eabb00f005d89e3b
MD5 669686b03b926a85084282cc817c3abe
BLAKE2b-256 0f8307978eee17f158b375f1b58c6b0b8bf3def191c6ae18d6ab158528656405

See more details on using hashes here.

Provenance

The following attestation bundles were made for alchemiq-0.2.0-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

0.2.2

2 files

0.2.1

2 files

This release

0.2.0 This release

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