Bridge is a cross-language ORM with a Python expression layer and a Rust execution engine. It combines the ergonomics of Python with the performance of native Rust code via PyO3 FFI.
Bridge splits the ORM into two layers:
- Expression Layer (Python): Thin API for model definition, query building, session management, hooks, and eager loading orchestration.
- Execution Engine (Rust): Built on
sqlxandtokio. Handles connection pooling, SQL construction, row hydration, circuit breaking, and telemetry.
Data crosses the language boundary through native memory bindings (PyO3), not HTTP or JSON pipes.
- Security first: No string interpolation in queries. Identifiers validated by regex. FFI wrapped in
catch_unwind. Circuit breaker prevents cascading failures. - Async throughout: Python
asynciodriving Rusttokio— no blocking calls. - 12 database dialects: PostgreSQL, SQLite, MySQL, MariaDB, Oracle, MS SQL Server, CockroachDB, PlanetScale, Neon, YugabyteDB, Cloudflare D1, Dolt.
- Identity Map + Dirty Tracking: Unit of Work pattern with snapshot-based diff and automatic flush on commit.
- Eager and lazy loading: Batch SELECT IN for to-many relations, JOIN-based for to-one, lazy proxies for deferred resolution.
- Schema migration engine: Snapshot-based diffing generates UP/DOWN SQL.
- Optional extras: Admin panel (FastAPI), REST API generator, Arrow IPC, OpenTelemetry, pytest fixtures, factory_boy support.
Bridge uses Cargo feature flags to keep the core lightweight:
| Feature | Description |
|---|---|
default |
No default features |
allow-raw-sql |
Enables execute_raw() and Raw SQL expressions |
data-science |
Enables Arrow IPC via fetch_arrow() |
java-interop |
Enables JNI bindings for Java interop |
- Quickstart — install and first query in 5 minutes
- Defining models
- Basic queries
- Relationships
- Query builder reference
- Transactions and sessions
- Migrations
- Python API reference