sqlite
Module[Sqlite]: the SQLite adapter.
use utopia_database::Adapter;
use utopia_database::adapter::sqlite::Sqlite;
let adapter = Sqlite::open("/tmp/app.sqlite")?;
adapter.set_namespace("_1")?;
adapter.create("appwrite").await?;Contents
6 submodules, and what the module defines itself.
use utopia_database::adapter::sqlite::Sqlite;pub struct SqliteThe SQLite adapter. See the module docs.
sqlite::ddl
Own pageTables, columns, relationship columns, indexes (FTS5 virtual tables for fulltext ones) and schema introspection.
sqlite::documents
Own pageDocuments: reads by id, creates, updates, upserts, deletes, sequence lookups and atomic increments, with their permission rows.
sqlite::find
Own pageFinds, counts and sums: WHERE conditions for every query method
(comparisons, LIKE with explicit escapes, REGEXP, FTS5 searches,
JSON array membership), cursor pagination and the document-level
permission filter.
sqlite::operators
Own pageOperators: atomic updates as SQL expressions (SQLite's JSON functions for arrays), and their effect on a default value for documents an upsert creates.
sqlite::pdo
Own pageThe adapter writes SQL with named placeholders (:_uid) and binds values
with a PDO parameter type. The sqlite driver prepares the statement as it
is (sqlite3_prepare_v2: SQLite reads :name placeholders itself, and
text after the first statement is ignored) and binds each value when the
statement executes, so Pdo does the same over rusqlite:
use utopia_database::adapter::sqlite::pdo::Executed;pub struct ExecutedA statement's result: what execute() returned, the rows and the row count.
use utopia_database::adapter::sqlite::pdo::Pdo;pub struct PdoThe PDO handle: one SQLite database file.
use utopia_database::adapter::sqlite::pdo::PdoError;pub struct PdoErrorA driver error (PDOException): its SQLSTATE, SQLite's result code
(errorInfo[1]) and its message.
use utopia_database::adapter::sqlite::pdo::Statement;pub struct StatementA prepared statement: SQL with named placeholders and bound values.
use utopia_database::adapter::sqlite::pdo::ParamType;pub enum ParamTypeA PDO parameter type (PDO::PARAM_*).
use utopia_database::adapter::sqlite::pdo::PdoFailure;pub enum PdoFailureA failed execute(): a driver error, or another exception (a value
that cannot be converted to a string).
From.use utopia_database::adapter::sqlite::pdo::to_long;pub fn to_long(value: &Value) -> i64Undocumented.
sqlite::sql
Own pageThe building blocks every statement uses: identifiers, table names, tenant conditions, column types, parameter types, statement execution, the mapping of driver errors onto the library's errors, and geometry text.
use utopia_database::adapter::sqlite::sql::Binds;pub struct Binds(pub Vec<(String, Value)>)Bound values of a statement in the making, by placeholder, in the order
they were added ($binds).
use utopia_database::adapter::sqlite::sql::array_to_wkt;pub fn array_to_wkt(geometry: &Array) -> Result<String>POINT(x y), LINESTRING(...) or
POLYGON((...), ...).
use utopia_database::adapter::sqlite::sql::bind_typed;pub fn bind_typed(stmt: &mut Statement, key: &str, value: Value) -> Result<()>$stmt->bindValue($key, $value, $this->getPDOType($value)).
use utopia_database::adapter::sqlite::sql::decode_linestring;pub fn decode_linestring(wkb: &[u8]) -> Result<Value>(SQL): [[x, y], ...].
use utopia_database::adapter::sqlite::sql::decode_point;pub fn decode_point(wkb: &[u8]) -> Result<Value>(SQL): [x, y] from WKT or SRID-prefixed WKB.
use utopia_database::adapter::sqlite::sql::decode_polygon;pub fn decode_polygon(wkb: &[u8]) -> Result<Value>(SQL): [[[x, y], ...], ...].
use utopia_database::adapter::sqlite::sql::filter;pub fn filter(value: &str) -> StringKeeps [A-Za-z0-9_-].
use utopia_database::adapter::sqlite::sql::has_sequence;pub fn has_sequence(document: &Document) -> Result<bool>!empty($document->getSequence()).
use utopia_database::adapter::sqlite::sql::id_value;pub fn id_value(document: &Document) -> Value$document->getId().
use utopia_database::adapter::sqlite::sql::internal_key;pub fn internal_key(attribute: &str) -> &strUndocumented.
use utopia_database::adapter::sqlite::sql::interpolate;pub fn interpolate(value: &Value) -> StringUndocumented.
use utopia_database::adapter::sqlite::sql::json_encode;pub fn json_encode(value: &Value) -> ValueThe JSON text, or false when it fails.
use utopia_database::adapter::sqlite::sql::json_text;pub fn json_text(value: &Value) -> StringAs text ("" when it fails, as interpolating
false gives).
use utopia_database::adapter::sqlite::sql::pdo_type;pub fn pdo_type(value: &Value) -> Result<ParamType>(MariaDB): strings and floats bind as strings, integers and booleans as integers.
use utopia_database::adapter::sqlite::sql::process_exception;pub fn process_exception(e: PdoError) -> Error(SQLite): driver errors SQLite reports for
existing and missing tables, unique violations and oversized values
become the library's errors; others stay PDOExceptions.
use utopia_database::adapter::sqlite::sql::processed;pub fn processed(e: PdoFailure) -> ErrorA failed statement through processException.
use utopia_database::adapter::sqlite::sql::quote;pub fn quote(s: &str) -> String(MariaDB): `string`.
use utopia_database::adapter::sqlite::sql::raw;pub fn raw(e: PdoFailure) -> ErrorA failed statement as it escapes unprocessed (PDOException).
use utopia_database::adapter::sqlite::sql::row_to_document;pub fn row_to_document(mut row: Array, find: bool) -> Result<Document>A fetched row as a document: internal columns renamed to their $
attributes, each renamed key moving to the end, in the order
getDocument() (find = false) or find() renames them.
use utopia_database::adapter::sqlite::sql::sequence;pub fn sequence(document: &Document) -> Result<Option<Value>>$document->getSequence(): null, or the value as a string (the
return type coerces it; an array is a TypeError).
use utopia_database::adapter::sqlite::sql::spatial_attributes;pub fn spatial_attributes(collection: &Document) -> Vec<String>Ids of the collection's spatial attribute documents.
use utopia_database::adapter::sqlite::sql::sql_type;pub fn sql_type(kind: &str, size: i64, signed: bool, array: bool, required: bool) -> Result<String>(MariaDB).
use utopia_database::adapter::sqlite::sql::string_attribute;pub fn string_attribute(document: &Document, key: &str, getter: &str) -> Result<Value>A ?string getter of a document (getCreatedAt(), getUpdatedAt()):
the raw value coerced to a string.
use utopia_database::adapter::sqlite::sql::tenant_value;pub fn tenant_value(document: &Document) -> Value$document->getTenant().
use utopia_database::adapter::sqlite::sql::type_from_wkt;pub fn type_from_wkt(wkt: &[u8]) -> Result<Vec<u8>>The lowercase type before (.
use utopia_database::adapter::sqlite::sql::violated_columns;pub fn violated_columns(message: &str) -> Option<Vec<String>>(SQLite): the sorted columns of
UNIQUE constraint failed: t.a, t.b, or None when the message has none.
pub const MAX_VARCHAR_LENGTH: i64 = 16381Undocumented.