Sticker to bind pydantic schemas with various datasources
Project description
Arcanus
Arcanus is a small library that binds Pydantic schemas to your datasource. The idea is to let you work with one set of typed, validated objects that are backed by your real backend records — so the templates, factories, and converters that usually sit between validation and persistence mostly fall away. If that boilerplate has bothered you too, this is the approach Arcanus takes to it.
It's a different take from SQLModel, which fuses the Pydantic
model and the ORM table into one class. Arcanus instead keeps them separate and binds a schema
to your existing ORM model with bless(), so your SQLAlchemy models stay untouched and your
validation schema stays your own.
⚠️ Work in progress. Arcanus is at an early, minimum-viable stage — expect bugs and breaking changes. SQLAlchemy is currently the only supported backend.
Features
- 🔄 Unified objects — transmuters are backed by ORM objects; changes sync both ways, no manual conversion.
- 🛡️ Type safety — full Pydantic validation, plus typed column references like
Author["name"]. - 🔗 Relationships — one-to-one, one-to-many, many-to-many, and keyed maps that respect lazy loading.
- ⚡ Async — native
async/awaitviaAsyncSession. - 🎯 Pluggable backends —
NoOpMateriafor tests,SqlalchemyMateriafor databases. - 📦 Partial models — built-in
Create/Updateshapes for API boundaries.
Installation
pip install "arcanus[sqlalchemy]"
The base pip install arcanus ships the in-memory NoOpMateria (no backend needed) — ideal for
tests and prototyping.
Quickstart
from arcanus.base import BaseTransmuter, Identity
from arcanus.association import Relation, RelationCollection, Relationship, Relationships
from arcanus.materia.sqlalchemy import SqlalchemyMateria, Session
from pydantic import Field
from sqlalchemy import create_engine, select
from typing import Annotated, Optional
materia = SqlalchemyMateria()
@materia.bless(AuthorModel) # bind to your existing SQLAlchemy model
class Author(BaseTransmuter):
id: Annotated[Optional[int], Identity] = Field(default=None, frozen=True)
name: str
books: RelationCollection["Book"] = Relationships()
@materia.bless(BookModel)
class Book(BaseTransmuter):
id: Annotated[Optional[int], Identity] = Field(default=None, frozen=True)
title: str
author: Relation[Author] = Relationship()
with Session(create_engine("sqlite://")) as session:
author = Author(name="Isaac Asimov")
session.add(Book(title="Foundation", author=Relation(author)))
session.commit()
# Plain SQLAlchemy reads — only the results come back as transmuters
found = session.execute(
select(Author).filter_by(name="Isaac Asimov")
).scalar_one() # a transmuter, not a raw ORM row
for book in found.books: # loads on access
print(book.title, book.author.value is found) # identity preserved
See the Quickstart guide for the full walkthrough including the ORM model definitions and async usage.
Documentation
Full documentation lives at kalynnka.github.io/arcanus:
- Why Arcanus — the problem it solves.
- Quickstart — define a transmuter and run CRUD.
- The Materia System — binding and design philosophy.
- API Reference — the full public API.
Contributing
See CONTRIBUTING.md for branch naming, conventional commits, and the release flow.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file arcanus-0.0.25.tar.gz.
File metadata
- Download URL: arcanus-0.0.25.tar.gz
- Upload date:
- Size: 343.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07ddf42738602236bd2ee3ca36639dec6ab3a6ea00f82a37dc7a18f8413263d4
|
|
| MD5 |
ac7d97e5eaab16058cd33a77c348e7c4
|
|
| BLAKE2b-256 |
7c855f5e9bcf6eaa23bc00421c82bc8d1f8e0e916f58bc03855774d51fffab79
|
Provenance
The following attestation bundles were made for arcanus-0.0.25.tar.gz:
Publisher:
publish.yml on kalynnka/arcanus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arcanus-0.0.25.tar.gz -
Subject digest:
07ddf42738602236bd2ee3ca36639dec6ab3a6ea00f82a37dc7a18f8413263d4 - Sigstore transparency entry: 1947617267
- Sigstore integration time:
-
Permalink:
kalynnka/arcanus@66d211359ad443371c58f3437d8d495bd1a456b8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kalynnka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@66d211359ad443371c58f3437d8d495bd1a456b8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file arcanus-0.0.25-py3-none-any.whl.
File metadata
- Download URL: arcanus-0.0.25-py3-none-any.whl
- Upload date:
- Size: 64.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a489dc129a91beeae3fb11fd4c47d582649559fb5870c14dce09eae901e98433
|
|
| MD5 |
c86cfccaabcade7b4958e15e33510370
|
|
| BLAKE2b-256 |
825ddf1fc28e3e3eb5db71979c4043f055ee10220b4935f64a00d7b09c0d3f52
|
Provenance
The following attestation bundles were made for arcanus-0.0.25-py3-none-any.whl:
Publisher:
publish.yml on kalynnka/arcanus
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
arcanus-0.0.25-py3-none-any.whl -
Subject digest:
a489dc129a91beeae3fb11fd4c47d582649559fb5870c14dce09eae901e98433 - Sigstore transparency entry: 1947617387
- Sigstore integration time:
-
Permalink:
kalynnka/arcanus@66d211359ad443371c58f3437d8d495bd1a456b8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/kalynnka
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@66d211359ad443371c58f3437d8d495bd1a456b8 -
Trigger Event:
push
-
Statement type: