SQLOrm
A modular, type-safe SQL ORM for Rust with procedural macro-based entity generation and a powerful query builder.
Architecture
SQLOrm is split into three main crates:
sqlorm
: The main crate that users depend onsqlorm-core
: Core traits and query builder implementationsqlorm-macros
: Procedural macros for entity generation
Database Support
SQLOrm supports two database backends via feature flags:
- PostgreSQL (
postgres
feature) - SQLite (
sqlite
feature)
⚠️ Important: Only one database driver can be active at a time.
Quick Start
Add SQLOrm to your Cargo.toml
:
[]
= { = "0.1", = ["postgres"] } # or "sqlite"
= { = "0.8", = ["postgres", "runtime-tokio-rustls", "chrono"] }
= { = "1.0", = ["full"] }
= { = "0.4", = ["serde"] }
Define Entities
use Entity;
use ;
Basic CRUD Operations
// Create
let user = User ;
// returns the inserted `User` record
let user = user.save.await?;
// Read
let user = find_by_id.await?;
let user = find_by_email.await?;
// Update
user.name = "Jane Doe".to_string;
let updated_user = user.save.await?;
// Query with filters
let users = query
.filter
.fetch_all
.await?;
Development Commands
or