Skip to main content

AlchemyManager

AlchemyManager is a lightweight Python ORM built on SQLAlchemy, inspired by Django’s ORM. It provides Django-like model API with objects manager, QuerySet, Q objects, and supports sync and async CRUD operations with automatic session management.


Features

  • Django-style Model.objects.create(), .get(), .filter(), .update(), .delete()
  • Q objects for complex queries with AND, OR, NOT, and multiple lookups (eq, lt, gt, contains, in)
  • Supports sync and async operations
  • Automatic session management
  • Optional explicit transaction scopes (sync_session_scope, async_session_scope)
  • Typed objects manager for IDE autocompletion and static checking
  • Bulk operations (bulk_create)
  • Works with SQLite, PostgreSQL, MySQL (via SQLAlchemy)

Installation

pip install alchemy-manager

Usage

Full Example

from alchemy_manager import Model, init_sync_db

from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import Integer, String, Boolean

class User(Model):
    __tablename__ = "users"

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    name: Mapped[str] = mapped_column(String(100))
    age: Mapped[int] = mapped_column(Integer, default=0)
    is_active: Mapped[bool] = mapped_column(Boolean, default=True)


if __name__ == "__main__":
    db_path = "sqlite:///test.db"
    init_sync_db(db_path)

    instance1 = User.objects.create(name="Alice", age=20)
    instance2 = User(name="Anthony", age=17).save()
    peoples = User.objects.filter(age_gte=18).all() #[User(name="Alice")]

Sync operations

# Create
user = User.objects.create(name="Alice", age=20)

# Get
user = User.objects.get(id=1)

# Filter
users = User.objects.filter(age__gte=18).all()

# Update
User.objects.filter(id=1).update(name="Bob")

# Delete
user.delete()

# Bulk create
User.objects.bulk_create([
    User(name="A"),
    User(name="B"),
])

Async operations

import asyncio

async def main():
    # Create
    user = await User.objects.acreate(name="Bob", age=30)

    # Get
    user = await User.objects.aget(id=1)

    # Filter
    users = await User.objects.filter(age__gte=18).aall()

    # Update
    await User.objects.filter(id=1).aupdate(name="Charlie")

    # Delete
    await user.adelete()

asyncio.run(main())

Explicit transaction scopes

from alchemy_manager import sync_session_scope, async_session_scope

# Sync
with sync_session_scope():
    user = User.objects.create(name="Scoped")
    user.save()

# Async
async with async_session_scope():
    user = await User.objects.acreate(name="AsyncScoped")

Q object usage

from alchemy_manager.queryset import Q

# Complex query
users = User.objects.filter(
    Q(age__gte=18) & ~Q(name__startswith="A")
).all()

Testing

pip install pytest pytest-asyncio
pytest -v

License

MIT License

Release files for alchemy-manager 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for alchemy-manager 0.0.4
File Size Uploaded
alchemy_manager-0.0.4.tar.gz 7.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for alchemy-manager 0.0.4
File Interpreter ABI Platform
alchemy_manager-0.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 14.7 kB

Release files / alchemy_manager-0.0.4.tar.gz

Download URL alchemy_manager-0.0.4.tar.gz
Size 7.2 kB
Tags Source
SHA-256 checksum
How to use checksums
88c7ad96c30af997ad4b6881d4947ba1a78da18caa62d97d18139f7e8d09da48
BLAKE2b-256 checksum
How to use checksums
7ddfe08c12215b66bbf2c3019e67c299e47ad018b18c17bc708979baba9f2b7a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 12, 2026.

Transparency log

Release files / alchemy_manager-0.0.4-py3-none-any.whl

Download URL alchemy_manager-0.0.4-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a830cb41362ea1397ef9b84f95267709781474e2278b2e5e7159923a5ccee47
BLAKE2b-256 checksum
How to use checksums
37bc4e191223e393f97f113a047e7c7c52ee7577f6dfbf59731708df79f22cd2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jan 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page