Documentation
¶
Overview ¶
Package sqliteread reads local SQLite stores that agents keep their session data in — today, Cursor's `state.vscdb` chat store.
It is a thin read-only layer over modernc.org/sqlite, a pure-Go SQLite that keeps the platform's CGO_ENABLED=0 builds working. The package exists to concentrate the rules for touching someone's live editor database in one place:
- Stores are opened with the URI parameter `mode=ro`, so SQLite refuses every write to the store. A store being read while Cursor is running is the normal case, and WAL-mode SQLite serves concurrent readers.
- A write-ahead log is applied, so rows Cursor has not checkpointed yet are visible. This is why `mode=ro` is used rather than `immutable=1`, which would ignore the log and quietly report stale data.
- Opening a WAL-mode store makes SQLite create a `<path>-shm` coordination file beside it when none exists. That file is ephemeral bookkeeping, not a change to the store; the store itself is never modified.
- If the store cannot be opened in place at all — a read-only directory, say — it is copied to a temporary file and the copy is read instead, so the answer stays correct rather than silently degrading.
The surface is deliberately small: list the tables, scan one wholly or by an indexed text prefix. Callers get decoded rows and do their own interpretation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotSQLite = errors.New("not a SQLite database file")
ErrNotSQLite reports a file that does not carry the SQLite header magic.
var ErrStopScan = errors.New("stop scan")
ErrStopScan ends a Scan early without reporting an error.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is an open read-only SQLite store.
func (*DB) Scan ¶
Scan calls fn for every row of the named table. Scanning stops and the error is returned when fn returns one; returning ErrStopScan stops without an error.
func (*DB) ScanPrefix ¶
ScanPrefix calls fn for rows whose named text column starts with prefix. The range predicate lets SQLite use the column's index instead of scanning the entire table. The column and table must both exist in the loaded schema.
type Row ¶
type Row struct {
Columns []string
Values []Value
// RowID is the row's integer key, set only for rowid tables.
RowID int64
}
Row is one decoded row. Values is positional and parallel to Columns.