deniz.in

Markets

Weather

Loading weather

· via dev.to (home feed)

LuaDB delivers an embeddable RDBMS in pure Lua with B+Trees, WAL and Postgres wire support

A developer has released LuaDB, an embeddable SQL database written entirely in pure Lua, featuring B+Tree indexes, write-ahead logging, ACID transactions, a PostgreSQL wire protocol server and pluggable storage including S3.

LuaDB delivers an embeddable RDBMS in pure Lua with B+Trees, WAL and Postgres wire support

A developer has released LuaDB, an embeddable SQL database engine written from scratch entirely in Lua, with no C extensions, native libraries or other external dependencies. The project was introduced in two dev.to posts published in late August 2026, and the source is available on GitHub under jncastilho/luadb.

Pages, B+Trees and a write-ahead log

The engine stores data in four-kilobyte binary pages arranged in a slotted layout, and uses B+Tree structures for both primary and secondary indexes. Durability comes from write-ahead logging: transactions are managed with explicit BEGIN, COMMIT and ROLLBACK statements, and the author describes the result as ACID-compliant.

The SQL layer goes beyond basic queries. One post lists native JSON and JSONB extraction using the -> and ->> operators, for example pulling a nested value such as a city out of an address field, plus foreign keys with ON DELETE CASCADE, ALTER TABLE-based migrations, and WITH clauses for common table expressions.

It speaks the PostgreSQL wire protocol

The most unusual feature for a pure-Lua project is a built-in server that implements the PostgreSQL wire protocol. Running luajit bin/luadb_server.lua starts the gateway, after which standard Postgres clients such as psql or DBeaver can connect and query the database. In practice this means a Lua-embedded database becomes inspectable with everyday operational tooling, without a Postgres installation anywhere in the picture.

Pluggable storage and replication

Storage sits behind a pluggable VFS layer. The post names three backends: local disk, in-memory RAM, and Amazon S3 authenticated with AWS SigV4. That last backend is what makes the cloud-sync use case plausible, since the same engine can write data directly to object storage.

The second post adds a feature the first omits: multi-master cluster replication using a hinted-handoff mechanism. Conversely, common table expressions appear only in the first post's feature list. The two write-ups therefore disagree slightly on scope, and the repository is the definitive reference for what the current release actually supports.

Aimed at games and embedded runtimes

The stated motivation is portability. Embedding SQLite normally means compiling native shared libraries or maintaining C bindings, which the author describes as friction on platforms like LÖVE, Roblox, OpenResty or small embedded devices. Because LuaDB is plain Lua, it runs anywhere Lua runs: the posts claim support for Lua 5.1 and later, including 5.4, 5.5 and LuaJIT.

The author pitches it specifically at game save files, state tracking and cloud synchronisation, and invites feedback and technical questions on the project.

Why it matters

Lua ships inside game engines, web servers and countless embedded systems, yet persistent structured storage has almost always meant binding to a native database. A dependency-free RDBMS collapses that deployment problem to copying scripts, and the Postgres wire support means developers can inspect live data with tools they already use. B+Trees, WAL and ACID semantics are the right foundations for an engine expected to hold player progress safely.

The open questions are maturity and performance. The posts include no benchmarks, load tests or production reports, and with both announcements only days old, the code itself is currently the only meaningful review. Still, the combination of an embedded engine, a wire-protocol server and S3-capable storage in a single pure-Lua package is an unusually complete feature set for this niche.

  • #lua
  • #databases
  • #sql
  • #open-source
  • #embedded

Related posts