Skip to main content

graphitesql/
lib.rs

1//! # graphitesql
2//!
3//! A pure, safe, `no_std`-capable Rust re-implementation of [SQLite].
4//!
5//! graphitesql is a single crate that reads and writes the **SQLite version 3
6//! on-disk file format** and speaks a large subset of SQLite's SQL dialect. It
7//! contains **no `unsafe`**, depends only on `core` + `alloc`, and is designed
8//! to run anywhere from a server to a WebAssembly sandbox.
9//!
10//! ## Status
11//!
12//! graphitesql opens real SQLite databases, runs SQL (`SELECT` with joins,
13//! aggregates, `GROUP BY`/`ORDER BY`/`LIMIT`; `CREATE TABLE`, `INSERT`,
14//! `UPDATE`, `DELETE`; transactions), and **writes databases the real
15//! `sqlite3` opens with `PRAGMA integrity_check = ok`**. It reads WAL-mode
16//! databases (overlaying the `-wal`). The architecture and remaining breadth
17//! work (indexes on write, more SQL) live in `ROADMAP.md`.
18//!
19//! ## Design goals
20//!
21//! * **File-format compatible.** A database created by SQLite must be readable
22//!   and writable by graphitesql and vice-versa, byte for byte.
23//! * **Safe.** `#![forbid(unsafe_code)]`. No FFI, no C, no `unsafe` blocks.
24//! * **Portable.** `#![no_std]` + `alloc`. Optional `std` feature adds a
25//!   file-backed VFS and `std::error::Error` integration.
26//! * **Single crate.** Everything (storage, B-tree, SQL, VM) lives here.
27//!
28//! ## Feature flags
29//!
30//! * `std` *(default)* — enables the [`std`]-file VFS and `std::error::Error`.
31//!   Disable for `no_std` targets; an in-memory VFS is always available.
32//! * `fts5` *(default)* — registers the built-in FTS5 full-text-search virtual
33//!   table (the `MATCH` query language, `bm25()`/`rank` ranking, `highlight()`).
34//!   Disable to drop full-text search and shrink the build.
35//!
36//! ## Attribution
37//!
38//! SQLite is public domain, created by D. Richard Hipp and contributors.
39//! graphitesql uses SQLite's source and documentation only as a specification
40//! reference; no SQLite code is compiled into this crate. See `NOTICE` and
41//! `ATTRIBUTION.md`.
42//!
43//! [SQLite]: https://www.sqlite.org/
44
45#![no_std]
46#![forbid(unsafe_code)]
47#![cfg_attr(docsrs, feature(doc_cfg))]
48
49extern crate alloc;
50
51#[cfg(feature = "std")]
52extern crate std;
53
54pub mod error;
55pub mod util;
56
57mod value;
58pub use value::{cmp_text, cmp_values, cmp_values_coll, Collation, SerialType, Value, ValueRef};
59
60pub mod btree;
61pub mod exec;
62pub mod format;
63#[cfg(feature = "fts5")]
64pub(crate) mod fts5_index;
65pub mod pager;
66pub mod schema;
67pub mod sql;
68pub mod vfs;
69pub mod vtab;
70
71pub use error::{Error, Result};
72pub use exec::{AggregateFactory, AggregateFunction, Connection, QueryResult, ScalarFunction};
73
74/// The version of the SQLite file format graphitesql targets.
75///
76/// graphitesql reads and writes file-format version 3, which has been stable
77/// and forward/backward compatible across every SQLite 3.x release.
78pub const SQLITE_FILE_FORMAT: u32 = 3;
79
80/// The SQLite release whose documented behavior graphitesql tracks as its
81/// compatibility target. See `ATTRIBUTION.md`.
82pub const TARGET_SQLITE_VERSION: &str = "3.53.2";