Expand description
§FeatherDB
An embedded SQL database for AI agents. Compiles into your binary — no servers, no sockets, no C dependencies.
Built on real database internals (B-trees, WAL, MVCC) with features agents actually need: concurrent writers, encryption at rest, API key auth, and per-session isolation.
§Quick Start
use featherdb::{Database, Result};
fn main() -> Result<()> {
let db = Database::open("myapp.db")?;
db.execute("CREATE TABLE tasks (
id INTEGER PRIMARY KEY,
title TEXT NOT NULL,
status TEXT DEFAULT 'pending'
)")?;
db.execute("INSERT INTO tasks (id, title) VALUES (1, 'Build something cool')")?;
let rows = db.query("SELECT * FROM tasks WHERE status = 'pending'")?;
println!("Found {} pending tasks", rows.len());
Ok(())
}§Transactions
use featherdb::{Database, Result};
fn main() -> Result<()> {
let db = Database::open("myapp.db")?;
let mut txn = db.begin()?;
txn.execute("INSERT INTO tasks (id, title) VALUES (2, 'Ship it')")?;
txn.execute("INSERT INTO tasks (id, title) VALUES (3, 'Celebrate')")?;
txn.commit()?; // atomic — both rows or neither
Ok(())
}§Encryption
use featherdb::{Config, Database, Result};
fn main() -> Result<()> {
let config = Config::new("secrets.db").with_password("hunter2");
let db = Database::open_with_config(config)?;
// Every page is AES-256-GCM encrypted at rest
Ok(())
}Re-exports§
pub use session::Session;pub use session::SessionConfig;pub use session::SessionHandle;pub use session::SessionId;pub use session::SessionManager;pub use session::SessionManagerConfig;pub use session::SessionMetadata;pub use session::SessionMode;pub use session::SessionState;
Modules§
- session
- Session management for MCP session lifecycle.
Structs§
- ApiKey
Info - Public metadata about an API key (no secrets)
- Buffer
Pool Stats Snapshot - Immutable snapshot of buffer pool statistics
- Cache
Stats - Statistics for the plan cache
- Catalog
- The schema catalog - manages all table and index definitions
- Column
- Column definition
- Column
Def - Column definition for schema generation
- Compression
Stats Snapshot - Immutable snapshot of compression statistics
- Config
- Database configuration options
- Database
- The main database handle
- Database
Metrics - Comprehensive database metrics snapshot
- Database
Stats - Database statistics
- Delete
Builder - Builder for DELETE queries
- Execution
Context - Execution context containing database state
- Executor
- Query executor
- GcMetrics
Snapshot - Index
- Index definition
- Insert
Builder - Builder for INSERT queries
- Lsn
- Log Sequence Number - identifies a position in the WAL
- Migration
- A schema migration record
- Optimizer
- Query optimizer that applies transformation rules
- PageId
- Page identifier - uniquely identifies a page in the database file
- Parser
- SQL parser wrapper with enhanced error messages
- Permissions
- Permission flags for table-level access control.
- Plan
Cache - LRU cache for query plans
- Plan
Cache Snapshot - Plan cache statistics snapshot
- Planner
- Query planner with enhanced error messages
- Prepared
Statement - A prepared statement with a cached, optimized query plan
- Query
Builder - Main entry point for the query builder
- Query
Metrics Snapshot - Snapshot of query metrics at a point in time
- Row
- A row of values
- Select
Builder - Builder for SELECT queries
- Snapshot
- A consistent view of the database at a point in time
- Storage
Quota - Storage quota information
- Table
- Table definition
- Table
Grant - A grant of permissions on a table to an API key
- Transaction
- A database transaction
- Transaction
Config - Configuration for transaction behavior
- Transaction
Id - Transaction identifier
- Transaction
Manager - Manages all transactions in the database
- Transaction
Metrics Snapshot - Snapshot of transaction metrics at a point in time
- Update
Builder - Builder for UPDATE queries
- WalStats
Snapshot - Immutable snapshot of WAL statistics
Enums§
- Aggregate
Function - Built-in aggregate functions
- Binary
Op - Binary operations between expressions
- Column
Constraint - Column constraint
- Column
Type - Column type definition
- Error
- Main error type for FeatherDB operations
- Eviction
Policy Type - Buffer pool eviction policy type
- Expr
- Expression tree
- Index
Type - Type of index
- Logical
Plan - Logical plan - represents a query as a tree of relational operators
- Query
Ordering - Sort ordering for ORDER BY
- Query
Result - Query result - either rows or affected count Query result
- Transaction
Mode - Transaction mode
- Transaction
Status - Transaction status
- UnaryOp
- Unary operations on expressions
- Value
- A database value
Traits§
- FromRow
- Trait for types that can be constructed from a database row
- From
Value - Trait for types that can be created from a database Value
- Table
Schema - Trait for types that have a table schema
- ToRow
- Trait for types that represent a database row
- ToValue
- Trait for types that can be converted to a database Value
Type Aliases§
- Result
- Result type alias using FeatherDB’s Error
- Savepoint
Id - Unique identifier for a savepoint
Derive Macros§
- Table
- Derive macro for generating table schema and row conversion implementations