Skip to main content

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

Project description

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.

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)
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/SQLite support, synchronous mode, multi-database routing, audit logs, geolocation fields, or file-field storage adapters.

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

Project details


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.1.0.tar.gz (438.8 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.1.0-py3-none-any.whl (183.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for alchemiq-0.1.0.tar.gz
Algorithm Hash digest
SHA256 69326d4555668c39e13a8d6f5b0a5aaa76b5f4536d31cd2511e7265d5fa235f9
MD5 c18b6e8d79c2b98bac77615d65215773
BLAKE2b-256 926e4b466847f9a11b8686b4c0845f335440c70ef8b4f7bdd1cf5ffd50633cf1

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: alchemiq-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 183.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9cb977290629b528a713ae3ab3fad25c4fd0c905d6af3e64a5175a31c3e76b1f
MD5 0dd4f19183abaffdd5eb30019e787fd3
BLAKE2b-256 a65efeaf29605360a0d7d23c5c5cad58bc5b16d75a25b8cb46cfd5214b3a1971

See more details on using hashes here.

Provenance

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

Supported by

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