EpilogLite is a pure Rust implementation of SQLite, designed for safety, reliability, and performance. Built with 100% safe Rust (no unsafe code), it provides a drop-in compatible alternative to SQLite with modern Rust idioms.
- β Full SQL Support - CREATE TABLE, INSERT, SELECT, UPDATE, DELETE
- β Disk Persistence - Data automatically saves to and loads from files
- β
In-Memory Databases - Fast
:memory:mode for temporary data - β Transactions - BEGIN, COMMIT, ROLLBACK, SAVEPOINT, RELEASE support
- β Multiple Tables - Create and manage multiple tables simultaneously
- β Fluent Interface - Type-safe query construction
- β SelectBuilder - Build SELECT queries with WHERE, ORDER BY, LIMIT
- β InsertBuilder - Build INSERT statements with column specification
- β UpdateBuilder - Build UPDATE statements with SET clauses
- β DeleteBuilder - Build DELETE statements with conditions
- β CreateTableBuilder - Build CREATE TABLE with columns and constraints
- β 17+ Native Rust Types - Bool, I8-I128, U8-U128, F32/F64, String, Vec
- β SQL Type Mapping - INTEGER, TEXT, REAL, BLOB, BOOLEAN
- β NULL Support - Proper NULL value handling
- β Type Checking - Built-in type validation
- β 100% Safe Rust - No unsafe code blocks
- β Modular Design - Clean separation of concerns
- β Error Handling - Comprehensive Result types
- β Test Coverage - 152 tests (124 unit + 18 adversarial + 10 integration)
- β Security Tested - SQL injection resistance, malformed input handling
- β Idiomatic Rust - Clippy-approved, modern patterns
- β Type Safety - ColumnType enum eliminates hardcoded strings
- π§ WHERE clause filtering
- π§ JOIN operations
- π§ Aggregate functions (COUNT, SUM, AVG, MIN, MAX)
- π§ ORDER BY and GROUP BY implementation
- π§ Index support
- β No-std Compatible - Works without standard library for embedded systems
- β In-memory Mode - Available in no-std environments
- β Custom Allocators - Bring your own allocator support
- π Unicode 16 support
- π Graph data structures
- π Role-based permissions
- π Lightweight ORM
- π REST/GraphQL API
- π SQLite C API compatibility
- π Embedded VFS for flash storage
Add to your Cargo.toml:
[dependencies]
epiloglite = "0.1"use epiloglite::{Database, ExecutionResult, Result};
fn main() -> Result<()> {
// Open or create a database file
let mut db = Database::open("mydata.db")?;
// Create a table
db.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT, age INTEGER)")?;
// Insert data
db.execute("INSERT INTO users VALUES (1, 'Alice', 30)")?;
db.execute("INSERT INTO users VALUES (2, 'Bob', 25)")?;
// Query data
let result = db.execute("SELECT * FROM users")?;
match result {
ExecutionResult::Select { rows, columns } => {
println!("Found {} rows", rows.len());
for row in rows {
println!("{:?}", row);
}
}
_ => {}
}
// Update data
db.execute("UPDATE users SET age = 31 WHERE id = 1")?;
// Delete data
db.execute("DELETE FROM users WHERE id = 2")?;
// Close database (auto-saves)
db.close()?;
Ok(())
}use epiloglite::{Database, SelectBuilder, InsertBuilder, UpdateBuilder, Result};
fn main() -> Result<()> {
let mut db = Database::open("mydata.db")?;
// Create table with builder
let sql = CreateTableBuilder::new()
.table("products")
.column("id", "INTEGER", &["PRIMARY KEY"])
.simple_column("name", "TEXT")
.simple_column("price", "INTEGER")
.build()?;
db.execute(&sql)?;
// Insert with builder
let sql = InsertBuilder::new()
.into("products")
.columns(&["id", "name", "price"])
.values(&["1", "'Widget'", "100"])
.build()?;
db.execute(&sql)?;
// Query with builder
let sql = SelectBuilder::new()
.select_all()
.from("products")
.where_clause("price > 50")
.order_by("name")
.limit(10)
.build()?;
let result = db.execute(&sql)?;
// Update with builder
let sql = UpdateBuilder::new()
.table("products")
.set("price", "120")
.where_clause("id = 1")
.build()?;
db.execute(&sql)?;
db.close()?;
Ok(())
}use epiloglite::{Database, Result};
fn main() -> Result<()> {
// Create in-memory database (faster, no disk I/O)
let mut db = Database::open(":memory:")?;
// Use like a regular database
db.execute("CREATE TABLE temp_data (id INTEGER, value TEXT)")?;
db.execute("INSERT INTO temp_data VALUES (1, 'test')")?;
// Data is lost when database is closed
db.close()?;
Ok(())
}EpilogLite can run without the standard library for embedded systems:
[dependencies]
epiloglite = { version = "0.1", default-features = false, features = ["no-std"] }#![no_std]
extern crate alloc;
fn main() -> Result<(), epiloglite::Error> {
// Create an in-memory database (no file I/O in no-std)
let mut db = epiloglite::Database::new()?;
db.execute("CREATE TABLE sensors (id INTEGER, value INTEGER)")?;
db.execute("INSERT INTO sensors VALUES (1, 23)")?;
let result = db.execute("SELECT * FROM sensors")?;
Ok(())
}See docs/NO_STD.md for detailed documentation and examples/embedded/ for more examples.
The examples/ directory contains several examples:
basic_usage.rs- Complete workflow demonstrationquery_builder_example.rs- Query builder pattern examplessavepoint_example.rs- Transaction savepoint operationsembedded/no_std_basic.rs- No-std embedded example
Run examples with:
cargo run --example basic_usage
cargo run --example query_builder_example
cargo run --example savepoint_example
# No-std build (won't run but demonstrates compilation)
cargo build --example no_std_basic --no-default-features --features no-stdEpilogLite follows a modular architecture:
eplite/
βββ command/ # SQL parsing and execution
β βββ tokenizer # Lexical analysis
β βββ parser # Syntax analysis
β βββ processor # Query execution
β βββ virtual_machine # Bytecode VM
βββ persistence/ # Storage engine
β βββ pager # Page cache management
β βββ btree # B-tree implementation
β βββ header # Database header
βββ storage/ # Table and row management
βββ query_builder/ # Fluent query interface
βββ os/ # OS abstraction layer
βββ types/ # Type system
Run the test suite:
# Run all tests
cargo test
# Run specific test category
cargo test integration
cargo test query_builder
# Run with output
cargo test -- --nocaptureCurrent test coverage: 93 tests passing (88 unit + 5 integration)
- Architecture - System architecture overview
- File Format - Database file format specification
- Virtual Machine - Bytecode execution engine
- C/C++ Interface - C API design (planned)
- Status - Current implementation status
- Contributing - Contribution guidelines
- Changelog - Version history
- 100% Safe Rust - No
unsafeblocks anywhere - Comprehensive Error Handling - All errors properly handled
- No Panics - Graceful error returns
- Memory Safe - Rust's ownership system prevents common bugs
- Thread Safe - Designed for concurrent access
EpilogLite aims to:
- Provide a safe alternative to SQLite using pure Rust
- Maintain SQLite 3 compatibility for existing databases
- Offer modern Rust idioms (builders, async, etc.)
- Support all major platforms (Windows, Linux, macOS, mobile, embedded)
- Achieve high performance without sacrificing safety
Contributions are welcome! See CONTRIBUTING.md for guidelines.
EpilogLite is licensed under the LGPL-3.0-only license.
Copyright (C) 2024 Tony M. Bishop
- SQLite project for the original design and inspiration
- Rust community for excellent tooling and libraries
For questions, issues, or contributions, please use GitHub Issues.