kitx-0.0.6 has been yanked.
KitX - Lightweight SQL Builder for Rust
A minimalistic SQL builder library based on sqlx, supporting SQLite and MySQL/MariaDB. Provides type-safe database operations with soft delete capabilities and global filters.
Features
Core Functionality
-
Type-Safe CRUD Operations
insert_one,insert_many,update_one,update_many,delete_one,delete_manywith transaction support -
Advanced Queries
fetch_all,fetch_by_key,fetch_one,fetch_paginated,fetch_by_cursor,exists,count -
Soft Delete Management
restore_one,restore_manywith global configuration -
Flexible Query Building
Supports JOINs, CASE WHEN, aggregations, and custom SQL extensions
Key Advantages
- 🚀 No ORM Overhead - Direct SQL interaction with builder pattern
- 🔧 Field Access API - Uses field_access for type-safe column operations
- 🌍 Global Filters - Apply tenant ID or soft delete filters across all queries
- 📦 Extensible - Easily add custom operations and query modifiers
Quick Start
1. Add Dependency
# Default SQLite and MySQL support
= "0.0.6"
# For SQLite only
= { = "0.0.6", = false, = ["sqlite"] }
# For MySQL/MariaDB only
= { = "0.0.6", = false, = ["mysql"] }
2. Basic Usage
use ;
// SQL Builder Example
let query = select
.filter
.filter
.or
.order_by
.build.0;
// CRUD Operations
let op = new;
let article = Article ;
// Insert with transaction
op.insert_one.await?;
3. Global Configuration
// Soft delete configuration
set_global_soft_delete_field;
// Multi-tenant filtering
set_global_filter;
Advanced Usage
Pagination Example
let results = op.fetch_paginated.await?;
Requirements
- Rust 1.85.0
- SQLite 3 or MySQL 5+
- sqlx-cli for migrations
License
MIT License