Prax
Prax is a modern, Prisma-inspired ORM for Rust with first-class async support. Built on top of tokio-postgres, sqlx, and other async database clients, Prax provides a type-safe, ergonomic API for database operations with compile-time guarantees.
⚠️ Work in Progress - Prax is currently under active development. See TODO.md for the implementation roadmap.
Features
- 🔒 Type-Safe Queries - Compile-time checked queries with zero runtime overhead
- ⚡ Async-First - Built on Tokio for high-performance async I/O
- 🎯 Fluent API - Intuitive query builder with method chaining
- 🔗 Relations - Eager and lazy loading with
includeandselect - 📦 Migrations - Schema diffing, SQL generation, and migration tracking
- 🛠️ Code Generation - Proc-macros for compile-time model generation
- 🗄️ Multi-Database - PostgreSQL, MySQL, and SQLite support
- 🔌 Framework Integration - First-class support for Armature, Axum, and Actix-web
Installation
Add Prax to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
For specific database backends:
# PostgreSQL (default)
= { = "0.1", = ["postgres"] }
# MySQL
= { = "0.1", = ["mysql"] }
# SQLite
= { = "0.1", = ["sqlite"] }
# Armature framework integration
= "0.1"
Quick Start
Define Your Models
use *;
Connect and Query
use *;
async
Armature Framework Integration
Prax integrates seamlessly with Armature, providing dependency injection support:
use *;
use PraxModule;
Query Operations
Filtering
// Equals
equals
// Contains, starts with, ends with
contains
starts_with
ends_with
// Comparisons
gt
gte
lt
lte
// Logical operators
and!
or!
not!
// Nested relation filters
some
Pagination
// Offset-based
client.user.find_many.skip.take.exec.await?;
// Cursor-based
client.user.find_many.cursor.take.exec.await?;
Aggregations
let count = client.user.count.exec.await?;
let stats = client
.post
.aggregate
.count
.avg
.sum
.exec
.await?;
let grouped = client
.user
.group_by
.count
.exec
.await?;
Architecture
Prax is organized as a workspace of focused crates:
prax/
├── prax-core/ # Core types, traits, and abstractions
├── prax-schema/ # Schema parser and AST
├── prax-codegen/ # Proc-macro crate for code generation
├── prax-query/ # Query builder implementation
├── prax-postgres/ # tokio-postgres query engine
├── prax-mysql/ # mysql_async query engine
├── prax-sqlite/ # rusqlite query engine
├── prax-migrate/ # Migration engine
├── prax-cli/ # CLI tool
├── prax-armature/ # Armature framework integration
└── prax/ # Main crate re-exporting everything
CLI
Prax includes a CLI for schema management and migrations:
# Install the CLI
# Initialize a new Prax project
# Generate client from schema
# Create a migration
# Apply migrations
# Reset database
# Introspect existing database
Comparison
| Feature | Prax | Diesel | SeaORM | SQLx |
|---|---|---|---|---|
| Async Support | ✅ | ❌ | ✅ | ✅ |
| Type-Safe Queries | ✅ | ✅ | ✅ | ✅ |
| Schema DSL | ✅ | ❌ | ❌ | ❌ |
| Migrations | ✅ | ✅ | ✅ | ✅ |
| Relations | ✅ | ✅ | ✅ | ❌ |
| Code Generation | ✅ | ❌ | ✅ | ❌ |
| Fluent API | ✅ | ❌ | ✅ | ❌ |
Contributing
Contributions are welcome! Please read the contributing guidelines before submitting a pull request.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Copyright (c) 2025 Pegasus Heavy Industries LLC
Acknowledgments
Prax is heavily inspired by: