DoltLite for Ruby: SQLite with Dolt-style
version control — dolt_commit, dolt_branch, dolt_merge, dolt_diff, and
the rest. A thin FFI layer over a bundled
libdoltlite; the dolt_* functions are reached through SQL.
gem install doltlitePrecompiled gems bundle libdoltlite for common platforms (Linux x86_64/arm64,
macOS arm64/x86_64), so no compiler is needed. The plain-Ruby gem falls back to
a system-installed libdoltlite.
require "doltlite"
db = Doltlite.open("app.db") # or ":memory:"
db.execute("CREATE TABLE notes(id INTEGER PRIMARY KEY, body TEXT)")
db.execute("INSERT INTO notes(body) VALUES (?)", "first note")
# A Dolt version-control commit (a new entry in dolt_log) — not a SQL
# transaction COMMIT. Equivalent to db.execute("SELECT dolt_commit('-A','-m',...)").
hash = db.dolt_commit(message: "add first note")
puts "committed #{hash}"
db.query("SELECT commit_hash, message FROM dolt_log").each do |commit_hash, message|
puts "#{commit_hash} #{message}"
end
db.closeexecute/query take positional bind values (?) and return rows as arrays of
column values. The dolt_* functions and virtual tables (dolt_log,
dolt_status, dolt_diff, dolt_branches, ...) are invoked through SQL.
dolt_commit is the version-control commit that adds to dolt_log — distinct
from a SQL transaction commit.
Apache-2.0. The bundled engine is built from dolthub/doltlite; SQLite itself is public domain.