lode_sql

The SQL layer for lode: the dialect-parameterized SQL renderer, the PostgreSQL adapter (via pog), the SQLite adapter (via sqlight), and migrations. Mirrors Elixir's ecto_sql package. Depends on the database-agnostic lode core.

lode is resolved from Hex. The runnable examples still build against this checkout and a sibling lode checkout by path, so to work on the examples clone the two repos side by side.

Modules

Tests

The Postgres and migration tests need a Postgres on localhost:5432 with a lode_test database the current OS user can reach:

createdb lode_test
gleam test

The SQLite tests (test/sqlite_test.gleam) run against sqlight.open(":memory:") and need no server.

Examples

examples/codegen_demo is a self-contained project showing the schema-first workflow: a hand-authored schema spec generates the typed schema modules offline (gleam run -m regenerate, no database), hand-written migrations drive Postgres, a drift check verifies the two agree, and the demo uses the generated module to insert/query/preload:

cd examples/codegen_demo
docker compose up -d
gleam run

examples/lustre_form is a full-stack demo: a shared validation core (dual-target lode, no SQL) reused by a Lustre client and a wisp server that persists with lode_sql against Postgres.