Database
SQL Server Connection
| Property | Value |
|---|---|
| Engine | SQL Server 2025 |
| Driver | Tiberius (pure Rust TDS protocol implementation) |
| Protocol | TDS 7.3 |
| ORM | None — hand-written SQL with parameterized queries |
| Async | Fully async via Tokio |
Multi-Region Architecture
Efision supports multiple database regions, each representing a separate business entity:
| Region | Flag | Environment Variables |
|---|---|---|
| Australia | -r au | DB_AU_HOST, DB_AU_PORT, DB_AU_NAME, DB_AU_USER, DB_AU_PASSWORD |
| United Kingdom | -r uk | DB_UK_* |
| United States | -r us | DB_US_* |
| Demo | -r demo | DB_DEMO_* |
Region resolution happens in crates/core/src/infrastructure/config.rs. The CLI’s --region flag selects which set of environment variables to use for the database connection.
Why No ORM?
Efision uses hand-written SQL instead of an ORM for several reasons:
- Legacy schema — 305 tables with non-standard naming conventions that don’t map cleanly to ORM patterns
- Performance — direct TDS protocol access avoids ORM overhead
- Complex queries — stored procedures, cross-table updates, and business-specific queries are easier to express in raw SQL
- Gradual migration — only the tables needed for current features are mapped as entities
Schema
The full database schema (305 tables) is available at docs/schema.sql in the repository.
Why Tiberius?
| Feature | Tiberius | pyodbc (Python) |
|---|---|---|
| Dependencies | Pure Rust (no C deps) | Requires ODBC driver |
| Async | Native async (Tokio) | No native async |
| Performance | ~5-7x faster | Baseline |
| Memory | ~10 MB | ~50 MB |
| Deployment | Single binary | Python runtime + driver |
| Platform | macOS, Linux, Windows | Same |
See SQL Server Compatibility for detailed driver research.