Chronicle

SQLite Store

Lightweight SQLite store for development, testing, and single-node deployments.

The store/sqlite package implements Chronicle's store.Store interface using the grove ORM with the SQLite driver. It requires no external database process, making it ideal for development, integration tests, and single-node deployments.

Import

import (
    "github.com/xraph/grove"
    "github.com/xraph/grove/drivers/sqlitedriver"
    "github.com/xraph/chronicle/store/sqlite"
)

Constructor

db, err := grove.Open(sqlitedriver.Open("chronicle.db"))
if err != nil {
    log.Fatal(err)
}

s := sqlite.New(db)

Pass ":memory:" for a fully in-process, zero-persistence store useful in tests:

db, err := grove.Open(sqlitedriver.Open(":memory:"))

Migrations

Run schema migrations before first use. Migrations are idempotent -- safe to run on every startup:

if err := s.Migrate(ctx); err != nil {
    log.Fatal(err)
}

Full setup with chronicle.New

import (
    "context"
    "log"

    "github.com/xraph/grove"
    "github.com/xraph/grove/drivers/sqlitedriver"
    "github.com/xraph/chronicle"
    "github.com/xraph/chronicle/store"
    "github.com/xraph/chronicle/store/sqlite"
)

ctx := context.Background()

db, err := grove.Open(sqlitedriver.Open("chronicle.db"))
if err != nil {
    log.Fatal(err)
}

s := sqlite.New(db)
if err := s.Migrate(ctx); err != nil {
    log.Fatal(err)
}

adapter := store.NewAdapter(s)

c, err := chronicle.New(chronicle.WithStore(adapter))

With the Forge extension

import "github.com/xraph/chronicle/extension"

ext := extension.New(
    extension.WithStore(s),
    // Migrate runs automatically on Start unless WithDisableMigrate(true)
)
app.Register(ext)

Interfaces implemented

sqlite.Store satisfies:

  • audit.Store
  • stream.Store
  • verify.Store
  • erasure.Store
  • retention.Store
  • compliance.ReportStore
  • store.Store (composite)

Characteristics

AspectDetail
Drivergrove ORM + sqlitedriver
Migrationsgrove orchestrator with programmatic migrations
ConcurrencyMultiple readers, single writer (WAL mode)
PersistenceFile-based or in-process (":memory:")
Recommended forDevelopment, integration tests, single-node deployments
Not recommended forHigh-throughput multi-writer production workloads

On this page