Skip to main content

Crate graphitesql

Crate graphitesql 

Source
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. #![forbid(unsafe_code)]. No FFI, no C, no unsafe blocks.
  • Portable. #![no_std] + alloc. Optional std feature adds a file-backed VFS and std::error::Error integration.
  • Single crate. Everything (storage, B-tree, SQL, VM) lives here.

§Feature flags

  • std (default) — enables the std-file VFS and std::error::Error. Disable for no_std targets; an in-memory VFS is always available.

§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 exec::Connection;
pub use exec::QueryResult;

Modules§

btree
B-tree layer: the table and index trees that hold all user data.
error
Error and result types.
exec
Query execution: the Connection API and the read-query executor.
format
The SQLite version 3 on-disk file format.
pager
The pager: turns a File into numbered fixed-size pages.
schema
The schema catalog: graphitesql’s view of what tables and indexes exist.
sql
The SQL front end: tokenizer, AST, and parser.
util
Low-level, fully-specified building blocks shared across the engine.
vfs
The OS abstraction layer: graphitesql’s only I/O boundary.

Structs§

SerialType
A SQLite record serial type code.

Enums§

Value
A value’s storage class, owning its data.
ValueRef
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_VERSION
The SQLite release whose documented behavior graphitesql tracks as its compatibility target. See ATTRIBUTION.md.

Functions§

cmp_values
Compare two values in SQLite’s total ordering: NULL < numbers < text < blobs; numbers compared numerically, text by byte (the BINARY collation), blobs by memcmp. This is the order used for index keys, ORDER BY, and comparisons (collation refinements are layered on top elsewhere).