BridgeORM uses the Performance Bridge principle by splitting the ORM into two distinct parts to maximize both Speed and Developer Ergonomics:
- Expression Layer (Python): A thin, expressive API that allows developers to write intuitive queries and models. It handles high-level logic and task-local identity mapping.
- Execution Engine (Rust): An ultra-fast core built on
sqlxandtokio. It handles connection pooling, SQL construction, row hydration, and cross-language telemetry.
Instead of slow HTTP or JSON-over-pipe communication, BridgeORM utilizes Native Memory Bindings (FFI), allowing data to flow between Python and Rust with near-zero latency.
BridgeORM provides native and protocol-compatible support for a wide range of modern and enterprise databases:
| Database | Compatibility | Specific Optimizations |
|---|---|---|
| PostgreSQL | Native | Full async support via sqlx. |
| SQLite | Native | High-performance local and embedded storage. |
| MySQL | Native | Standard industry support with backtick quoting. |
| MariaDB | Native | Specialized MariaDB dialect optimizations. |
| Oracle | Custom | Custom :1 placeholders & FETCH NEXT pagination. |
| MS SQL Server | Native | Support for [] quoting and @p1 placeholders. |
| CockroachDB | Postgres-Protocol | Optimized for distributed UUIDs and SERIAL8. |
| PlanetScale | MySQL-Protocol | Optimized for Vitess-based serverless pooling. |
| Neon | Postgres-Protocol | Native support for serverless Postgres architecture. |
| YugabyteDB | Postgres-Protocol | Built for distributed SQL workloads. |
| Cloudflare D1 | SQLite-Protocol | Optimized for serverless SQLite environments. |
| Dolt | MySQL-Protocol | Native support for versioned SQL databases. |
When I started designing BridgeORM, my absolute priority was Security. Iโve tried my best to build a secure wall around your data.. Here is how BridgeORM protection works around your data:
- Forbidden String Interpolation: I have strictly forbidden string interpolation in queries. If it's not parameterized, it doesn't run. Period.
- Rust-Level Guardrails: Before any dynamic SQL identifier even reaches the database, the Rust Engine forces it through a strict regular expression validator. No sneak attacks.
- Panic-Proof FFI: The language boundary is wrapped in
catch_unwindblocks. If something goes wrong in the Rust core, your Python app won't crash; it gets a clean exception. - Strict Type Coercion: We don't guess types. Every piece of data crossing the bridge is validated against your model's metadata. No silent data corruption.
- The Circuit Breaker: If your database starts failing or slowing down, our internal circuit breaker trips. This protects your application from cascading failures and keeps your threads alive.
Collaborator Must Follow This Rules:
- Self-Documenting Code: Meaningful identifiers Must. If something doesn't make sense to you; then rename it to something appropriate so that its logic will inspire clarity.
- Single Responsibility Principle: Each method must have only one responsibility and be of equal simplicity.
- D.R.Y. Principle: Do not duplicate common functionality; instead; utilise a single reference point when using common functionality.
- Meaningful Identifier: Write your identifiers as if they were spoken words. Use common sense when naming them; avoid unnecessary jargon names; and choose names with the focus of clarity.
- Avoid Magic Number/Strings: Use variable constants for hard-coded numbers/strings, so their meaning is clear.
- Explicit Handling of Errors: Fix the actual problem first (i.e., fix the code), then use either typed return value or exception handling to guarantee that the error is visible and cannot go unaddressed.
- Consistent Formatting: Use automated tools for visual consistency across the entire codebase (if possible).
- Provide Explanation to your Intent: Comment on your code to explain "why" you made those coding decisions versus only providing commentary on "what" the code is doing.
- FFI Boundary Safety: Any new feature crossing the Python/Rust boundary MUST be wrapped in the
ffi_guard!macro to ensure the application remains crash-safe. - Dialect Agnosticism: Never write SQL that is specific to one database in the core engine. Always use the
Dialecttrait to ensure your change works across Postgres, MySQL, Oracle, and others. - Telemetry Integrity: Every new database operation must include tracing spans. If we can't measure it, we shouldn't merge it.
- Eager Loading: Relations currently utilize high-speed Lazy Loading; native
prefetch_relatedis on the roadmap. - SQL Complexity: Advanced operations like CTEs and Window Functions require the
execute_raw()fallback. - Identity Isolation: The Identity Map is strictly scoped per
asyncio.Taskto ensure memory safety.