
A stupid simple WAL-based embedded database in Nim 👑
nimble install boogie
- BTrees storage and Hash Tables for fast lookups
- Write-ahead log (WAL) for durability and crash recovery
- Simple API for inserting, updating, deleting, and querying records
- Configurable options for performance tuning, such as batch sizes and flush intervals
- In-memory or On-disk storage modes
- Primitive data types (
string,int,float,bool,json,null)
Note
Boogie is an experimental project mostly made with the chatbot for fun and learning. It is still in early stages, so expect data loss and breaking changes. Use at your own risk.
This can be used as a simple embedded database for your Nim applications. If you want, you can use openpeeps/e2ee to encrypt the data before inserting it into Boogie database.
Here is a simple example of how to use Boogie
import pkg/boogie
var db = newStore("tests" / "data" / "myboogie.db", StorageMode.smDisk,
enableWal = true, walFlushEveryOps = 100'u32)
# Create a table with some columns
db.createTable(newTable(
name = "users",
primaryKey = "id",
columns = [
newColumn("id", DataType.dtInt, false),
newColumn("name", DataType.dtText, false),
newColumn("age", DataType.dtInt, false),
newColumn("active", DataType.dtBool, false),
newColumn("meta", DataType.dtJson, true)
]
))
# insert some data
db.insertRow("users", row({
"name": newTextValue("Alice"),
"age": newIntValue(30),
"active": newBoolValue(true),
"meta": newJsonValue(%*{"hobbies": ["reading", "hiking"]})
}))
# flush the WAL to disk (when enabled)
db.checkpoint()
# Query the data
for row in db.getTable("users").get().allRows():
for key, col in row[1]:
echo fmt"{key}: {$col}"Check the tests for more examples.
- Add support for multiple tables
- Add basic tests and benchmarks
- 🐛 Found a bug? Create a new Issue
- 👋 Wanna help? Fork it!
- 😎 Get €20 in cloud credits from Hetzner
LGPLv3 license. Made by Humans from OpenPeeps.
Copyright OpenPeeps & Contributors — All rights reserved.