Skip to main content

SQLite Driver

SQLite is useful for tests, local tooling, and single-process applications.

Packages

import (
"database/sql"

"github.com/yaop-labs/queen"
"github.com/yaop-labs/queen/drivers/sqlite"
_ "github.com/mattn/go-sqlite3"
)

db, err := sql.Open("sqlite3", "./app.db?_journal_mode=WAL")
if err != nil {
return err
}

q := queen.New(sqlite.New(db))

How it works

AreaImplementation
Migration tableSQLite table with WITHOUT ROWID.
Identifier quotingDouble quotes.
Placeholders?.
Timestamp parsingQueen parses SQLite text timestamps.
LockingSets busy_timeout, sets locking_mode=EXCLUSIVE, runs BEGIN IMMEDIATE, then commits.
Executiondatabase/sql transaction through the shared base driver.
Atomic recordNo. Migration body commits before Record.

Guarantees

  • SQL statements supported by SQLite transactions are run inside a transaction.
  • The driver works well for in-memory and file-backed local databases.

Limitations

  • The current lock path does not hold a pinned lock transaction for the full migration duration.
  • Do not use SQLite locking as distributed coordination between multiple migrator processes.
  • Metadata record writes are not atomic with the migration body.
  • Some SQLite DDL behavior depends on SQLite version and pragma settings.
./app.db?_journal_mode=WAL&_busy_timeout=5000