Sway ORM
Sway ORM is a type-safe, asynchronous ORM for PostgreSQL with Pydantic models and a Rust core.
Requires PostgreSQL 18+ and Python 3.15+. CI tests PostgreSQL 18 and 19. The Rust core checks the server version when connecting. Both postgres:// and postgresql:// connection URLs are supported.
Features
-
Pydantic v2 models with validation, type hints, and serialization.
-
Familiar
Model.objects.filter()queries, joins, relationship prefetch, aggregates, and bulk operations. -
Native PostgreSQL arrays, JSONB, enums, UUIDs, decimals,
RETURNING, and row locks. -
Array and JSON lookups:
contains,contained_by, andoverlap. -
Async transactions with nested savepoints and public transaction-depth reporting.
-
PostgreSQL
LISTEN/NOTIFYsubscriptions on dedicated connections withdb.listen(). -
Composite primary keys and declarative TimescaleDB hypertables.
-
Schema migrations with extension management, PostgreSQL advisory locking, and transactional DDL.
-
Rust SQL generation, connection pooling, and native Python rows for ORM reads.
-
Atomic get-or-create and scan I/O statistics on PostgreSQL 19.
-
Cache-disabled unnamed statements for PostgreSQL/PgBouncer, including cold custom-type decoding without replaying queries.
-
Generated type stubs for models and queries, checked with mypy, pyright, and ty.
Installation
pip install sway-orm
sway-orm includes the Python ORM and its Rust extension, sway._sway_core. The ORM import and CLI are both sway.
To build this checkout:
uv venv --python 3.15
source .venv/bin/activate
uv pip install maturin
make build-core-dev
Quick start
import asyncio
from sway import Field, Model, db
from sway.db.schema import create_tables
class User(Model):
id: int | None = Field(default=None, db_pk=True)
name: str
email: str = Field(db_unique=True)
tags: list[str] = Field(default_factory=list)
class Meta:
is_table = True
async def main():
await db.init(default="postgresql://user:password@localhost:5432/app")
try:
connection = await db.get_connection()
await create_tables(connection)
await User.objects.create(
name="Alice", email="alice@example.com", tags=["python"]
)
users = await User.objects.filter(tags__contains=["python"]).all()
print(users)
finally:
await db.close()
asyncio.run(main())
For managed schema changes, run sway init, sway makemigrations, and sway migrate. See the documentation, connection guide, and contributor guide.
See the changelog for release notes.
License
Sway ORM is available under the MIT license. The bundled SQLx PostgreSQL driver carries its MIT and Apache-2.0 licenses.
Metadata
Release files for sway-orm 1.0.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 |
|---|---|---|---|---|
| sway_orm-1.0.0.tar.gz | 817.0 kB | Without provenance | Details for sway_orm-1.0.0.tar.gz |
Built distributions (wheels)
Total release size: 83.4 MB
Release files / sway_orm-1.0.0.tar.gz
| Download URL | sway_orm-1.0.0.tar.gz |
|---|---|
| Size | 817.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
73e8d7dedd9145c08f1139d20a170ff8d8790e2b5f178fe508942496749e41fa
|
|
BLAKE2b-256 checksum How to use checksums |
56bf829f8459eb9fe6e66b149796db2346964df132a22362cafb751f2306c4a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315t-win_amd64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315t-win_amd64.whl |
|---|---|
| Size | 5.6 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Windows x86-64 |
|
SHA-256 checksum How to use checksums |
5a0fa2841bc47cc13fe89a110ffb9cda467c4bbfa74ad7d66bfc46f1957f8e43
|
|
BLAKE2b-256 checksum How to use checksums |
1b6a056d9622c562cb5a2d955a731aa57c10160b6e6a2ac76529ccbe94b89ce7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315t-musllinux_1_2_x86_64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315t-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.7 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
f5e75146e6c02e6815389e9512fd0c56a66e5053bb63b60ce56f9028988b3cbd
|
|
BLAKE2b-256 checksum How to use checksums |
5c2caf3ac72b27b5c9b7e7687acf925c5a6b5ded95fcf7492a977c2f2f9d093b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315t-musllinux_1_2_aarch64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315t-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
69ce74bd1cfac8f075f8384630a6b017e23d92e238e02d4988b1d216e3ea7259
|
|
BLAKE2b-256 checksum How to use checksums |
5086054ab7479d383f90dd388cf6da673ce26c3e80112cf77f68df5c466dc0b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315t-manylinux_2_28_x86_64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315t-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 7.5 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
acc15947320636401f8680bfc50d347d3e648584a2d6b3c8f0b8c97a7007f3a3
|
|
BLAKE2b-256 checksum How to use checksums |
f5d39612567bc0db7750e2a2adc21e9931d781774156e2500ac2d863cdfae811
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315t-manylinux_2_28_aarch64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315t-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
3bf56ddbc7519fe2e62d7cb789cc2269d80b13629e92b9274894738fa2f12a55
|
|
BLAKE2b-256 checksum How to use checksums |
b9d6c2582b72cdd87e4d4650a0f1ca095b41cd92770e625cc1a64e196e40bfb3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315t-macosx_11_0_arm64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315t-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.15 CPython 3.15 free-threading macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
36aa9c69fb6a79fca3f268467264cf4a6bd5aaa948ffb0b3e8c66ed978444913
|
|
BLAKE2b-256 checksum How to use checksums |
83600947f5301a1a18cf0a0f3591086c35dfc729e38e65fd183a360206ab4ab8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315-win_amd64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315-win_amd64.whl |
|---|---|
| Size | 5.6 MB |
| Tags | CPython 3.15 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
098fe47961b61a3d63ff483045b68bbf49ff4e29f83403b18b1900f8bda10ca7
|
|
BLAKE2b-256 checksum How to use checksums |
74fb74efaa01099b7388f99a6dbc98b9fb07216d683e0b8deb4f30b130ed0de0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315-musllinux_1_2_x86_64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 7.7 MB |
| Tags | CPython 3.15 Linux musl 1.2+ x86-64 |
|
SHA-256 checksum How to use checksums |
822832c8df838add94b6eaad644e9b56dc5e887ce4772f545c1446796a91cea0
|
|
BLAKE2b-256 checksum How to use checksums |
b005573894777e4e14b7be3133b43be3152f7ffcf1c6a9b7843744ccc2c78e9a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315-musllinux_1_2_aarch64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 7.4 MB |
| Tags | CPython 3.15 Linux musl 1.2+ ARM64 |
|
SHA-256 checksum How to use checksums |
43a367bbcffe6de7e3fdea2a44becd79f4195320988e4e1c260886927cc9cf92
|
|
BLAKE2b-256 checksum How to use checksums |
f04605e23b9463e4fb45a381b8727ff2071ea12861a4590f307fef34637f2007
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315-manylinux_2_28_x86_64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 7.5 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ x86-64 |
|
SHA-256 checksum How to use checksums |
07c909f3aa9e7c3a2ebf9d71eb34533e8073030ce006f8e89548fa99bcc53527
|
|
BLAKE2b-256 checksum How to use checksums |
dd899c53cfaf54e27b208936979794e2cf1f78141fd6c0a9ea3e396d28321838
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315-manylinux_2_28_aarch64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 7.2 MB |
| Tags | CPython 3.15 Linux glibc 2.28+ ARM64 |
|
SHA-256 checksum How to use checksums |
989143e6787fda4eabef97f85900b710724da3d1151094109ab9b87c800fdf4b
|
|
BLAKE2b-256 checksum How to use checksums |
3f9781d13591cc53e84bfdbaa6fb5cccd75d7e02d34cd35844e8e190bf9f05a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / sway_orm-1.0.0-cp315-cp315-macosx_11_0_arm64.whl
| Download URL | sway_orm-1.0.0-cp315-cp315-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.9 MB |
| Tags | CPython 3.15 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
75e9cc707afef75c5754f0336fe12ac959c63d818bcedccf5c702a3de01606a4
|
|
BLAKE2b-256 checksum How to use checksums |
ac53aafcb1bb3b05e3f0b0e4163dccee391016fd1e01b89da2e95f9f3a866884
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.10 {"installer":{"name":"uv","version":"0.13.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for sway-orm 1.0.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.