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.
lode/query/sql— render aQuery(and INSERT/UPDATE/DELETE) to parameterized SQL in a dialect (sql.postgres()/sql.sqlite()).lode/adapters/postgres— alodeadapter built onpog.lode/adapters/sqlite— alodeadapter built onsqlight(in-memory or file databases; no server).lode/migration,lode/migration/ddl— the typed, auto-reversible migration DSL.lode/migrator—migrate/rollback/statusover aschema_migrationstable — the DDL dialect is inferred from the adapter's engine.
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 testThe SQLite tests (test/sqlite_test.gleam) run against
sqlight.open(":memory:") and need no server.
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 runexamples/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.