Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • lode/query/sql — render a Query (and INSERT/UPDATE/DELETE) to parameterized SQL in a dialect (sql.postgres() / sql.sqlite()).
  • lode/adapters/postgres — a lode adapter built on pog.
  • lode/adapters/sqlite — a lode adapter built on sqlight (in-memory or file databases; no server).
  • lode/migration, lode/migration/ddl — the typed, auto-reversible migration DSL.
  • lode/migratormigrate / rollback / status over a schema_migrations table — the DDL dialect is inferred from the adapter's engine.

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.

About

The SQL layer for lode: a parameterized SQL renderer, PostgreSQL and SQLite adapters, hand-authored migrations with a CLI, schema-first codegen, and a spec-vs-database drift checker.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages