adorm
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 -n 4 # four workers (pytest-xdist); without -n the tests run in one process
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). Under pytest-xdist each worker uses <name>_<worker> (adorm_test_gw0 …) as its
<name>, so workers share no database or role. 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.
The codespace runs the demo with a PostgreSQL server of its own.
demo/backend: a Django project with the applibrary;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.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| adorm-0.1.0.tar.gz | 304.6 kB | Without provenance | Details for adorm-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| adorm-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for adorm-0.1.0-py3-none-any.whl |
Total release size: 639.2 kB
Release files / adorm-0.1.0.tar.gz
| Download URL | adorm-0.1.0.tar.gz |
|---|---|
| Size | 304.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f84ac7f2c736f415786c150fd5cd85845586077701a6cc3db94ed4f4b1f1394e
|
|
BLAKE2b-256 checksum How to use checksums |
12e551b9f6778aeb923f42d77525f588ac6649cd90b67aa778bb595d1871a1b3
|
| 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.1.0-py3-none-any.whl
| Download URL | adorm-0.1.0-py3-none-any.whl |
|---|---|
| Size | 334.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6cbef9304066577080629a837bba47edb9df9d6fa6cd92d79a10e05ca327673
|
|
BLAKE2b-256 checksum How to use checksums |
9b3a56e9588d756b907d415246b16d72973f73e38cc242feec663bb9289e19b1
|
| 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.1.0
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.