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.1.tar.gz (452.1 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.1-py3-none-any.whl (187.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: alchemiq-0.2.1.tar.gz
  • Upload date:
  • Size: 452.1 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.1.tar.gz
Algorithm Hash digest
SHA256 8a07cdbcefb5480f425f64e834eee002df4e86d0a174bea3f71550fc311c7a52
MD5 17af98d7ec9f4cd57afd7836ee94f439
BLAKE2b-256 9e015862159b0d56bdab9e245d2ac95b12fe054cc2aa6d1d3c1f6972f54086e3

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: alchemiq-0.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a968c49ebccce634b9369e51d43fcbdb8b7c03b02b1e5cad01b01fb008e4b23
MD5 a68006928f140ae0b34072c29f05a761
BLAKE2b-256 06c243113beb48228a0f6d9c0907554d693df005d043d25557aadbc023b204c3

See more details on using hashes here.

Provenance

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

This release

0.2.1 This release

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