SQLite
SQLite is the most deployed database engine in the world -- yet it was locked behind C expertise, native toolchains, and platform-specific binaries.
Core trick
Reimplements SQLite's pager, B-tree, bytecode compiler, and VDBE in pure Ruby, validated against reference SQLite database files.
Tags
Description
SQLite is the most deployed database engine in the world -- yet it was locked behind C expertise, native toolchains, and platform-specific binaries. The knowledge to reimplement it -- B-trees, bytecode compilation, virtual machine execution -- was reserved for specialists. AI breaks that barrier. It takes something powerful locked behind expertise and infrastructure and puts it in everyone's hands.
And yes, sqlite-purerb changes that. Built with Claude Code, we reimplemented SQLite's internals entirely in pure Ruby: the pager, B-tree, bytecode compiler, and VDBE.
Claude Code made this feasible. It navigated SQLite's C source, translated low-level algorithms into idiomatic Ruby, and drove a test-driven workflow validated against the reference implementation.
This project joins Ruby's "Rewrite C in Ruby" revolution. Pure Ruby means true portability -- no compiler needed.
README excerpt
# sqlite-purerb
A pure Ruby implementation of the SQLite database file format and SQL query engine. This library can read SQLite 3.x database files and execute SQL queries without any C extensions or FFI bindings.
The status is experimental project.
## Usage
### CLI
An interactive REPL is available at `bin/sqlite-purerb`. It works like the C `sqlite3` shell:
```sh
# Interactive mode
bin/sqlite-purerb path/to/database.sqlite3
sqlite-purerb> .headers on
sqlite-purerb> SELECT * FROM my_table LIMIT 5;
# Piped mode
echo "SELECT * FROM my_table;" | bin/sqlite-purerb path/to/database.sqlite3
```
Supported dot-commands: `.headers on|off`, `.mode list`, `.separator <sep>`, `.quit`, `.exit`.
### REPL (from Ruby code)
`SqlitePurerb::REPL` processes batch SQL input and produces formatted output, matching the C sqlite3 shell's behavior:
```ruby
require 'sqlite_purerb'
repl = SqlitePurerb::REPL.new('path/to/database.sqlite3')
output = repl.process(<<~SQL)
.headers on
SELECT * FROM my_table LIMIT 5;
SQL
puts output
repl.close
```
### Direct API
Use `SqlitePurerb::Database` for programmatic access. Queries return an array of hashes keyed by column name:
```ruby
require 'sqlite_purerb'
db = SqlitePurerb::Database.new('path/to/database.sqlite3')
# Execute a query
rows = db.execute('SELECT id, name FROM users')
rows.each { |row| puts row.inspect }
# => {"id"=>1, "name"=>"Alice"}
# => {"id"=>2, "name"=>"Bob"}
# List tables
puts db.tables
# Show EXPLAIN bytecode for a que