Expand description
§graphitesql
A pure, safe, no_std-capable Rust re-implementation of SQLite.
graphitesql is a single crate that reads and writes the SQLite version 3
on-disk file format and speaks a large subset of SQLite’s SQL dialect. It
contains no unsafe, depends only on core + alloc, and is designed
to run anywhere from a server to a WebAssembly sandbox.
§Status
graphitesql opens real SQLite databases, runs SQL (SELECT with joins,
aggregates, GROUP BY/ORDER BY/LIMIT; CREATE TABLE, INSERT,
UPDATE, DELETE; transactions), and writes databases the real
sqlite3 opens with PRAGMA integrity_check = ok. It reads WAL-mode
databases (overlaying the -wal). The architecture and remaining breadth
work (indexes on write, more SQL) live in ROADMAP.md.
§Design goals
- File-format compatible. A database created by SQLite must be readable and writable by graphitesql and vice-versa, byte for byte.
- Safe.
#![deny(unsafe_code)]— the entire SQL/storage engine isunsafe-free. The onlyunsafein the crate lives in the two opt-in FFI binding shims (capi,wasm), each#[allow(unsafe_code)]and off by default; the default build contains nounsafeand no FFI. - Portable.
#![no_std]+alloc. Optionalstdfeature adds a file-backed VFS andstd::error::Errorintegration. - Single crate. Everything (storage, B-tree, SQL, VM, and the optional C-ABI / WebAssembly bindings) lives here.
§Feature flags
std(default) — enables thestd-file VFS andstd::error::Error. Disable forno_stdtargets; an in-memory VFS is always available.fts5(default) — registers the built-in FTS5 full-text-search virtual table (theMATCHquery language,bm25()/rankranking,highlight()). Disable to drop full-text search and shrink the build.capi— alibsqlite3-compatible C ABI (extern "C"sqlite3_*symbols); builds thecdylib/staticlib. Pulls instd. Usesunsafe(raw pointers).wasm— WebAssembly (browser) bindings viawasm-bindgen, with an OPFS-backed VFS. Usesunsafe(wasm-bindgen glue) andjs-sys/web-sys.
§Attribution
SQLite is public domain, created by D. Richard Hipp and contributors.
graphitesql uses SQLite’s source and documentation only as a specification
reference; no SQLite code is compiled into this crate. See NOTICE and
ATTRIBUTION.md.
Re-exports§
pub use error::Error;pub use error::Result;pub use session::Changeset;pub use session::ConflictAction;pub use session::ConflictType;pub use session::Rebaser;pub use session::Session;
Modules§
- error
- Error and result types.
- session
- Change-tracking sessions that produce SQLite-compatible changesets.
- vfs
- The OS abstraction layer: graphitesql’s only I/O boundary.
Structs§
- Connection
- A database connection. Supports reading (
query) and writing (execute), over a file or in memory. - Query
Result - The result of a query: column labels and the materialized rows.
- Serial
Type - A SQLite record serial type code.
- Text
- A SQL text value — a byte string that is usually UTF-8.
Enums§
- Collation
- A text collating sequence.
BINARY(the default) compares bytes;NOCASEfolds ASCII letters;RTRIMignores trailing spaces.Customis an application-registered sequence (seeConnection::register_collation), identified by a small id into a process-global registry so this enum staysCopy/Send/Sync. Collations only affect text-vs-text comparison; storage-class ordering is unchanged. - Update
Op - The kind of row change reported to an update hook.
- Value
- A value’s storage class, owning its data.
- Value
Ref - A borrowed view of a
Value, used on hot decode paths to avoid copying.
Constants§
- SQLITE_
FILE_ FORMAT - The version of the SQLite file format graphitesql targets.
- TARGET_
SQLITE_ SOURCE_ ID - The value returned by the
sqlite_source_id()SQL function. - TARGET_
SQLITE_ VERSION - The SQLite release whose documented behavior graphitesql tracks as its
compatibility target. See
ATTRIBUTION.md.
Traits§
- Aggregate
Function - A user-defined aggregate’s accumulator:
stepis called once per group row with the evaluated argument values, thenfinalizeproduces the result. A fresh accumulator is created (by the registered factory) for each group.
Functions§
- cmp_
text - Compare two text strings under
coll. - cmp_
values - Compare two values in SQLite’s total ordering:
NULL< numbers < text < blobs; numbers compared numerically, text by byte (theBINARYcollation), blobs bymemcmp. This is the order used for index keys,ORDER BY, and comparisons (collation refinements are layered on top elsewhere). - cmp_
values_ coll - Like
cmp_valuesbut applyingcollto text-vs-text comparison.
Type Aliases§
- Aggregate
Factory - Builds a fresh
AggregateFunctionaccumulator per group. Registered withConnection::register_aggregate_function. - Scalar
Function - A user-defined scalar function: it receives its evaluated argument values and
returns a result
Value(or an error). Registered withConnection::register_function.