sqlite-embedded

command
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

Using Grizzle with embedded SQLite

Overview

In-process declarative migrations for embedded SQLite with zero Cgo (pure-Go modernc.org/sqlite). The same schema.sql single-source-of-truth workflow as the PostgreSQL example, but the shadow compile runs in an in-memory database — fully offline.

Usage pattern

  1. Open the database with sql.Open("sqlite", dsn); a sqlite:// or .db DSN selects the SQLite dialect automatically (or set Dialect: grizzle.DialectSQLite explicitly).
  2. Call grizzle.Sync(ctx, db, grizzle.Options{SchemaSQL: schemaSQL}) — no network, no locks beyond SQLite's own file locking.
  3. Column type changes and drops route through Grizzle's SQLite 12-step table rebuild engine (chunked keyset copy, savepoint isolation, foreign-key validation, trigger/view preservation).

SQLite scope notes

  • Multi-schema is supported via TargetSchemas + SQLiteAttach (ATTACH DATABASE). Cross-database FKs are not enforced by SQLite and are not validated.
  • CHECK constraints are parsed from sqlite_schema DDL, emitted on create/rebuild, and diffed (drift rebuilds the table; removals need AllowDropCheck + DROP_CHECK).

Running

go run .                # uses ./app.db by default
go test -tags integration ./...

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL