Skip to content

io.db.sqlite: the Sqlite transport and its constructor - #10

Merged
ewiger merged 3 commits into
mainfrom
feat/io-db-sqlite
Nov 12, 2026
Merged

ewiger merged 3 commits into
mainfrom
feat/io-db-sqlite

Conversation

@ewiger

@ewiger ewiger commented Nov 12, 2026

Copy link
Copy Markdown
Owner

What

The Sqlite transport of HQL-0047, in the module HQL-0048 names. A program reaches a table of a database file without a configured endpoint:

import io.db.sqlite

type Order { id : Int, customer : String }

orders : Seq<Order> = source(sqlite("data/shop.db", table = "orders", order = ["id"]))
orders | filter(o => o.id > 1) | target(sqlite("out.db", table = "big"))
  • Type and module: Sqlite : {Direct, RowTransport, Replayable, Writable} in io.db.sqlite. The constructor sqlite(path, table, order = []) takes the keys of kind = "sqlite", and the module is imported by its full path.
  • Reading: source gives a Seq<Data>, tap a Stream<Data>. An annotated read decodes each column through the format's boundary (an INTEGER 1 as true, a TEXT decimal with its digits) and reads only the columns the record names, as a configured table does.
  • Writing: target writes a declared record, one column per field, replacing the rows the table held.
  • Refused at check time: a format (a row transport takes none), values that are not a declared record, and sink. As for configured sqlite endpoints, a database file is written whole, by target.
  • Paths: a relative path resolves as file(...) does. A rendered document reads only databases under its directory and writes none.

Docs

The changelog, generated reference pages for io.db.sqlite, HQL-0048's status table, and book chapter 15 ("Transports") with a checked example against the shop's data/shop.db.

Testing

tests/io_db_sqlite.rs does round trips against real database files in a temporary directory. cargo test --locked (653), cargo clippy --locked --all-targets -- -D warnings, cargo fmt --check, hql reference --check and mkdocs build --strict pass locally.

`sqlite(path, table, order = [])` constructs one table of a database file
as `Sqlite : {Direct, RowTransport, Replayable, Writable}` (HQL-0047,
HQL-0048). `source` gives its rows as a `Seq<Data>` and `tap` as a
`Stream<Data>`; an annotated read decodes each column through the format's
boundary, reading only the columns the record reads. `target` writes a
declared record a column per field, replacing the table. A row transport
takes no format, and `sink` to it is refused, naming `target`.
@ewiger ewiger self-assigned this Nov 12, 2026
@ewiger
ewiger merged commit 2a64376 into main Nov 12, 2026
5 checks passed
@ewiger
ewiger deleted the feat/io-db-sqlite branch November 12, 2026 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant