Next-generation async ORM for Python with a Rust-powered core
Project description
Ferrum
A next-generation async ORM for Python. Rust-powered engine. Pydantic-native models. Django-inspired developer experience.
Ferrum is an async-first ORM designed for modern Python applications.
Built around a Rust-powered core and a Python-native API, Ferrum combines the ergonomics of Django's ORM, the type safety of Pydantic, and the performance of Rust.
Why Ferrum?
Existing Python ORMs often force developers to choose between:
- Developer experience
- Async support
- Type safety
- Performance
Ferrum aims to provide all four.
Goals
- Native async from day one
- Pydantic-first models
- Django-inspired ORM experience
- Rust-powered query engine
- PostgreSQL-first architecture (MySQL, SQLite, and SQL Server via optional extras)
- Type-safe query construction
- Automatic migrations
- High-performance result hydration
- Production-ready observability
Quick Example
from ferrum import Model
class User(Model):
id: int
email: str
is_active: bool = True
user = await User.objects.create(
conn,
email="john@example.com",
)
users = await (
User.objects
.filter(is_active=True)
.order_by("-id")
.limit(10)
.all(conn)
)
async with conn.transaction() as tx:
user = await User.objects.create(tx, email="jane@example.com")
await AuditLog.objects.create(tx, user_id=user.id, action="signup")
Features
Async First
No synchronous compatibility layer.
Ferrum is designed around modern async Python applications.
users = await User.objects.all(conn)
Pydantic Native
Models are built directly on top of Pydantic.
class User(Model):
id: int
email: str
No duplicate schema definitions.
Django-Inspired API
Familiar query interface.
users = await (
User.objects
.filter(email__contains="@gmail.com")
.order_by("-created_at")
.all(conn)
)
Rust-Powered Core
Performance-critical components are implemented in Rust:
- Query compilation
- SQL generation
- Result decoding
- Schema analysis
- Migration planning
This allows Ferrum to maintain a Pythonic API without sacrificing performance.
Cross-Driver Full-Text Search
Native full-text search across PostgreSQL, MySQL, SQLite FTS5, and SQL Server — one QuerySet API, dialect-specific SQL emit and migration DDL.
Query modes (filter lookups and ranking):
| Mode | Lookup operator | Typical use |
|---|---|---|
plain |
__match |
Natural-language terms |
phrase |
__match_phrase |
Exact phrase |
websearch |
__match_websearch |
Web-style quotes, - negation |
boolean |
__match_boolean |
Boolean operators (&, |, !) |
Convenience methods:
# Filter + relevance ranking in one call
hits = await Article.objects.search(
"python async orm", field="body", mode="websearch"
).limit(10).all(conn)
# Rank without an implicit filter
ranked = await Article.objects.rank_by("body", "rust", mode="plain").all(conn)
Index declaration — PostgreSQL uses TSVector columns; other drivers index base
text columns via Meta.full_text_indexes:
from ferrum.models import Field, FullTextIndex
class Article(Model):
search_vector: Annotated[TSVector, Field(fts_config="english")] | None = None
body: str = ""
class Meta:
full_text_indexes = [FullTextIndex(fields=("body",), config="english")]
Query strings are always bound parameters; fts_config and index names come from
model-metadata allowlists only. See Getting Started → Vector and full-text columns
and API Reference for per-dialect DDL and operator mapping.
Architecture
┌──────────────────────────┐
│ Python API │
│ Models / QuerySets │
└────────────┬─────────────┘
│
▼
┌──────────────────────────┐
│ Ferrum Core │
│ (Rust Engine) │
├──────────────────────────┤
│ Query Compiler │
│ SQL AST │
│ Result Decoder │
│ Migration Planner │
└────────────┬─────────────┘
│
▼
┌──────────────────────────┐
│ PostgreSQL │
└──────────────────────────┘
Roadmap
v0.1 (complete)
- PostgreSQL support
- Basic CRUD operations
- Async query execution
- Pydantic models
- Query builder
- Type-safe filters
- Transactions and savepoints
- Bulk operations (
bulk_create,bulk_update,bulk_delete) - Migrations (schema diff, apply, revert, CLI)
- Relationships (ForeignKey, OneToOne, ManyToMany)
- pgvector KNN search and HNSW/IVFFLAT index DDL
- Full-text search (cross-dialect: PostgreSQL, MySQL, SQLite FTS5, SQL Server)
- Observability hooks (Tier A/B/C)
- CLI (
makemigrations,migrate,revert,showmigrations,inspectdb,resetdb)
v0.2 (in progress)
- Upsert API (
upsert,bulk_upsertwith conflict targets andRETURNING) - Composite primary keys
- Array field types (
uuid[],text[], scalar arrays) - JSONB operators (
__contains,__has_key) - RLS / tenant session helpers (
set_config,tenant_session) -
call_functionfor allowlisted stored-procedure calls - Migration ops for extensions, RLS policies, and function DDL
- pgvector similarity score projection (
vector_searchhelper) - Query optimization (deferred fields, prefetch tuning)
- Advanced relationship loading
v1.0
- Production-ready stability
- Performance benchmarking suite
- Full documentation site
Project Status
Ferrum is currently in active development.
The API is not yet stable and breaking changes should be expected until the first public release.
Installation
# PostgreSQL (most common)
pip install 'ferrum-orm[pg]'
# PostgreSQL + migrations CLI
pip install 'ferrum-orm[pg,cli]'
# MySQL
pip install 'ferrum-orm[mysql]'
# SQLite + migrations CLI (testing / local dev)
pip install 'ferrum-orm[sqlite,cli]'
# SQL Server (also needs a system ODBC driver, e.g. msodbcsql18)
pip install 'ferrum-orm[mssql]'
# Optional MessagePack wire format for the Python<->Rust boundary
pip install 'ferrum-orm[msgpack]'
# Everything (all drivers + CLI + dotenv)
pip install 'ferrum-orm[all]'
# Core ORM only (no database driver — install a driver extra before connecting)
pip install ferrum-orm
Bare ferrum-orm installs Pydantic and the Rust core only. Choose a driver extra
(pg, mysql, sqlite, or mssql) before calling ferrum.connect().
MySQL, SQLite, and SQL Server are thin-parity backends: they support core CRUD
and migrations but not transactions, upsert, bulk_update, RLS, or pgvector
(PostgreSQL only). SQL Server connects via aioodbc/pyodbc and requires a system
ODBC driver such as msodbcsql18; DSNs use the mssql:// or sqlserver:// scheme.
Wire format (advanced)
The Python↔Rust IR/hydration boundary defaults to JSON. Installing the msgpack
extra lets you switch it to MessagePack, selected via the FERRUM_WIRE_FORMAT
environment variable (json | msgpack) or the [ferrum] wire_format key in
ferrum.toml / pyproject.toml. JSON remains the default; MessagePack is opt-in.
From source, build the native extension with maturin develop (or mise run dev).
Examples
Runnable samples live under examples/:
examples/simple/— async CRUD script (no web framework)examples/migrations/— CLI, plan generation, apply, and forward fix-upsexamples/fastapi_quickstart/— FastAPI integration
Contributing
Contributions are welcome. Start with CONTRIBUTING.md for local setup,
scoped verification, architecture rules, and pull request expectations.
License
Apache License 2.0
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
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 ferrum_orm-0.1.4.tar.gz.
File metadata
- Download URL: ferrum_orm-0.1.4.tar.gz
- Upload date:
- Size: 165.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da85938d293e9c1cb093fadea178bc4a69898fb76f25ca4b07598706a01c86c5
|
|
| MD5 |
3a6d86546bc5b440230e4d7e4dba3bd0
|
|
| BLAKE2b-256 |
384823f09a973e8802c80e267716d2bf1a21af7e6b6e62924abea20619b680b5
|
Provenance
The following attestation bundles were made for ferrum_orm-0.1.4.tar.gz:
Publisher:
release.yml on ferrum-orm/ferrum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ferrum_orm-0.1.4.tar.gz -
Subject digest:
da85938d293e9c1cb093fadea178bc4a69898fb76f25ca4b07598706a01c86c5 - Sigstore transparency entry: 2032602043
- Sigstore integration time:
-
Permalink:
ferrum-orm/ferrum@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ferrum-orm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Trigger Event:
push
-
Statement type:
File details
Details for the file ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 817.9 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94b080cdaabf38d81b5a73b13805a302422eb8eef1eedb12e205761ae6ea6748
|
|
| MD5 |
02fda7ca39f199ec367ef6cf9be612b9
|
|
| BLAKE2b-256 |
dbb8c72b4e81161ddca5e639c3ff9023132cae2891df71500fdbfe8dcf419e65
|
Provenance
The following attestation bundles were made for ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_x86_64.whl:
Publisher:
release.yml on ferrum-orm/ferrum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
94b080cdaabf38d81b5a73b13805a302422eb8eef1eedb12e205761ae6ea6748 - Sigstore transparency entry: 2032602120
- Sigstore integration time:
-
Permalink:
ferrum-orm/ferrum@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ferrum-orm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Trigger Event:
push
-
Statement type:
File details
Details for the file ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 796.7 kB
- Tags: CPython 3.11+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a10eb731cc5ffd9ef8c14640150f4d166af631d7aaa126af72e544ae371a4f3
|
|
| MD5 |
0542e45cb0c8e4cf0764b3ea5b43e00e
|
|
| BLAKE2b-256 |
7edd7f149a950f26f70c6a8482309e9a93a439cc7c752ee5dda3b7ca154fb4ac
|
Provenance
The following attestation bundles were made for ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_aarch64.whl:
Publisher:
release.yml on ferrum-orm/ferrum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ferrum_orm-0.1.4-cp311-abi3-manylinux_2_28_aarch64.whl -
Subject digest:
0a10eb731cc5ffd9ef8c14640150f4d166af631d7aaa126af72e544ae371a4f3 - Sigstore transparency entry: 2032602395
- Sigstore integration time:
-
Permalink:
ferrum-orm/ferrum@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ferrum-orm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Trigger Event:
push
-
Statement type:
File details
Details for the file ferrum_orm-0.1.4-cp311-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: ferrum_orm-0.1.4-cp311-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 748.0 kB
- Tags: CPython 3.11+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1fbdbc3b1a68a41fb248f7fcfb27243da01bcdb2b39b6e2bf973a6df5f910ba
|
|
| MD5 |
88932e28c20bd56b33ec2d90df1615f3
|
|
| BLAKE2b-256 |
54b9074eebc48f835e8e0466fefd10b15fa8e4df2ad2b3dd91623f87ead7b5a4
|
Provenance
The following attestation bundles were made for ferrum_orm-0.1.4-cp311-abi3-macosx_11_0_arm64.whl:
Publisher:
release.yml on ferrum-orm/ferrum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ferrum_orm-0.1.4-cp311-abi3-macosx_11_0_arm64.whl -
Subject digest:
f1fbdbc3b1a68a41fb248f7fcfb27243da01bcdb2b39b6e2bf973a6df5f910ba - Sigstore transparency entry: 2032602323
- Sigstore integration time:
-
Permalink:
ferrum-orm/ferrum@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ferrum-orm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Trigger Event:
push
-
Statement type:
File details
Details for the file ferrum_orm-0.1.4-cp311-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: ferrum_orm-0.1.4-cp311-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 777.4 kB
- Tags: CPython 3.11+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a78cdfbb77d2e42f9bd2f0eb90c42bdef65c0baa27cb51f82150ff058dd08571
|
|
| MD5 |
507767ca8511ff78255fc6738644d47e
|
|
| BLAKE2b-256 |
98241aeeb9d90e6764a65d155556219c97020ca73c5e5f4b70164bd0979816d0
|
Provenance
The following attestation bundles were made for ferrum_orm-0.1.4-cp311-abi3-macosx_10_12_x86_64.whl:
Publisher:
release.yml on ferrum-orm/ferrum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ferrum_orm-0.1.4-cp311-abi3-macosx_10_12_x86_64.whl -
Subject digest:
a78cdfbb77d2e42f9bd2f0eb90c42bdef65c0baa27cb51f82150ff058dd08571 - Sigstore transparency entry: 2032602212
- Sigstore integration time:
-
Permalink:
ferrum-orm/ferrum@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/ferrum-orm
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1a53840ddaf9705a5c80bbd3e1191bc93eed21ec -
Trigger Event:
push
-
Statement type: