Skip to main content

Module sqlite

Module sqlite 

Source
Expand description

SQLite databases, read only.

A database is a file of tables. One with a single table of its own opens it; one with several is a place on the home screen whose rows are its tables, each named by a path inside the file (app.db/users) that nothing on disk has. --table picks one by name either way.

A table is read in place. The dataset’s frame is a scan of it (open_table) whose windows SQLite reads by the table’s key, so the first rows show at once and the last page costs what the first does; the sidebar’s filters and sort run in SQLite as WHERE and ORDER BY (see crate::pushdown), where its indexes serve them, and the row count is SQLite’s count(*). What reads the whole view (analysis, a query, an export) has it read a batch at a time from SQLite, and nothing is copied to disk.

Nothing is written to the database. It is opened read only, with query_only, defensive mode and an untrusted schema, and with extension loading left out of the build. Reading a table runs no trigger. A database in WAL mode with a -wal file is read through it, and SQLite creates the -shm index beside it if that is missing; one with no -wal is read as it stands (immutable=1), writing nothing. A database that cannot be read without writing beside it (a hot journal, or a -wal without its -shm in a read-only directory) is refused rather than read wrong.

Re-exports§

pub use crate::members::place as table_place;
pub use crate::members::split as table_path;

Structs§

Hold
Held by a dataset read in place: dropped, whatever SQLite is running for it stops.
Opened
A table opened in place, as the dataset takes it.
Table
One table of a database, as its schema describes it.

Enums§

Affinity
How SQLite reads a declared type: the affinity rules of its documentation, in order, so VARCHAR(10) is text and POINT (holding “INT”) an integer.
Pick
What opening a database without --table finds: its one table of its own, or the names of several, which the home screen lists.

Constants§

MAGIC
The first sixteen bytes of every SQLite 3 database.
SCAN_NAME
The name a SQLite scan carries in a plan.

Functions§

detail
The SQLite tab of the Info panel for the database at path, whose tables the open listed: the database’s page size and versions, and each table of its own with its kind, columns and the rows ANALYZE stored for it. Nothing here reads a table: a count of every table’s rows would be a pass over the whole database.
is_sqlite_file
Whether the file at path is a SQLite database, by its first bytes.
looks_like
Whether head, the first bytes of a file, begins a SQLite database.
open_table
Open table of the database file (named display to the user) in place: the frame over it, what the dataset runs its filters and sort through, and the hold that stops its statements when the dataset lets go. others are the database’s other tables, for the Info panel.
pick
The table wanted names among tables, or the database’s one table of its own when nothing is named. display names the database in errors.
schema_preview
The columns table opens with, read from its first rows the way the open decides them, for the home screen’s preview. Gives up after a moment.
tables
The tables and views of the database at path, SQLite’s own included, in the order they were created; the schema table last.