Skip to main content

adorm

PyPI Python Licence

adorm (asynchronous database ORM, pronounced "adore") is a pure async ORM for Python: every call that touches the database is a coroutine or returns an awaitable. Applications build queries and model operations with adorm's API; a driver executes them, natively on the event loop (PostgreSQL through asyncpg) or through a synchronous database library or ORM (Django). adorm's pool runs a synchronous library on a thread owned by one slot, with that slot's connection, so the event loop never runs synchronous database code. The API is modelled on the Django ORM.

Documentation: https://docs.velis.si/adorm/ (quick start, API reference, changelog)

adorm is pre-alpha (0.0.x): the API can change in any release.

Installation

pip install "adorm[django]"     # the Django ORM driver
pip install "adorm[asyncpg]"    # the native PostgreSQL driver: asyncpg, Django and psycopg 3

Both drivers need Python 3.11 or newer and Django 5.2 or newer: the native PostgreSQL driver compiles its SQL with Django's query compiler.

Example

import adorm

from myapp.adorm_models import Activity, Member


async def rename_member(member_id: int, name: str) -> None:
    async with adorm.atomic():
        member = await Member.objects.get(pk=member_id)
        member.name = name
        await member.save()
        await Activity.objects.create(member_id=member.pk, kind="renamed")


async def active_names() -> list[str]:
    return [m.name async for m in Member.objects.filter(active=True).order_by("name")]

myapp.adorm_models is generated from the Django models with adorm generate; the quick start sets up a project from start to finish.

Development

The project uses uv. The test suite needs PostgreSQL; the conformance run on SQLite needs no database server (Python's sqlite3).

uv sync
uv run ruff check .
uv run ruff format --check .
uv run pytest
npm install
npm run lint              # eslint, markdownlint and type checks of the demo; `npm run lint -- --fix` fixes

The tests read the test database URL from ADORM_TEST_DATABASE_URL (default postgres://postgres@127.0.0.1:5432/adorm_test). On that server they create and drop the database it names (<name>: ADORM_TEST_DATABASE_NAME when set, adorm_test when the URL names postgres or none) and the databases <name>_demo, <name>_demo_owner, <name>_limited, <name>_parallel and <name>_parallel_<n> (the clones of manage.py test --parallel). Other databases and the server's roles are left untouched; runs with different names on one server leave each other's databases alone. A run that leaves any of these databases, or a role named <name>_…, on the server fails. Run the tests as a dedicated user with CREATEDB. Under a superuser the test of the pool's refusal handling is skipped, because a database's connection limit does not apply to a superuser, and so are the tests of the demo, which refuses a superuser:

CREATE ROLE adorm LOGIN CREATEDB PASSWORD '...';

ADORM_TEST_CREATE_ROLES=1 also runs the tests of the role connection option. They create and drop the roles <name>_login, <name>_alice and <name>_bob and need CREATEROLE. Roles belong to the whole server and outlive the test databases: set the variable only on a server dedicated to the tests. CI runs the suite with CREATEDB only, then grants CREATEROLE and runs these tests separately.

The demo reads its database URL from ADORM_DEMO_DATABASE_URL. Both variables can be set in .env in the repository root (ignored by git; .env.example lists them). Variables set in the environment take precedence.

cp .env.example .env    # then fill in the user and password
uv run pytest

The conformance suite also runs the Django driver on SQLite, in a database file in a temporary directory, without PostgreSQL:

uv run pytest --ds=tests.djangoproject.settings_sqlite tests/conformance

Demo

demo.py runs the demo application, a library on PostgreSQL: every example and concurrency scenario on every available driver, with the adorm code, the SQL each driver sent, the result and the time side by side.

Open in GitHub Codespaces

The codespace runs the demo with a PostgreSQL server of its own.

  • demo/backend: a Django project with the app library;
  • demo/models: the adorm models generated from it;
  • demo/api: a FastAPI app running the examples and scenarios;
  • demo/frontend: the Vue frontend; demo/e2e: its Playwright tests.

It creates (owned by the user of ADORM_DEMO_DATABASE_URL, which must not be a superuser), migrates and seeds the demo database, then serves the API and the Vite dev server on http://127.0.0.1:5173/.

npm install
uv run python demo.py
npm run test:e2e

Documentation

The documentation site is in docs/ (VitePress, published on https://docs.velis.si/adorm/):

npm install
npm run docs:dev

Licence

MIT, see LICENSE.

Metadata

Release files for adorm 0.0.3

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

Source distribution (sdist)

Source distribution for adorm 0.0.3
File Size Uploaded Provenance Actions
adorm-0.0.3.tar.gz 282.6 kB Without provenance Details for adorm-0.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adorm 0.0.3
File Interpreter ABI Platform Actions
adorm-0.0.3-py3-none-any.whl Python 3 none any Details for adorm-0.0.3-py3-none-any.whl

Total release size: 595.2 kB

Release files / adorm-0.0.3.tar.gz

Download URL adorm-0.0.3.tar.gz
Size 282.6 kB
Tags Source
SHA-256 checksum
How to use checksums
1715bd1082afa94a835574824d5012b96c84ac9a4dd1d360d396472426a6554c
BLAKE2b-256 checksum
How to use checksums
92ea2b4d2bbfaede6e7ac25e9f93df9ccd1c9f929443bb284d086380deafe0ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / adorm-0.0.3-py3-none-any.whl

Download URL adorm-0.0.3-py3-none-any.whl
Size 312.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9bd4010e9788269dccf0366a4fcd2f1c3bde4a2f3c71a86e1ec2af30da9773a
BLAKE2b-256 checksum
How to use checksums
869aceeed88b2e58672f766c04d1a89e63ac5d67302f1262e770ade7201e8193
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for adorm 0.0.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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