Documentation
¶
Overview ¶
Package sqlite connects rio, the zero-surprise Go ORM, to SQLite through the pure-Go modernc.org/sqlite driver — no cgo required.
Driver modules are deliberately thin. This package contains exactly three things, and nothing else:
- Constructors: Open (from a DSN) and New (bring your own *sql.DB), both returning a *rio.DB speaking the built-in rio.SQLite dialect.
- Precise error translation: SQLite constraint failures become rio.ErrDuplicateKey and rio.ErrForeignKeyViolated, with the driver error kept in the chain for errors.As.
- DSN hygiene: Open enables foreign key enforcement and a busy timeout unless the DSN sets those pragmas itself.
All SQL grammar lives in github.com/go-rio/rio; this package never implements a dialect.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New wraps an existing *sql.DB — bring your own connection pool — in a *rio.DB speaking the rio.SQLite dialect with this package's error translator installed. A rio.WithErrorTranslator among opts wins over the built-in translator.
New performs no DSN hygiene, because the pool already exists. In particular, foreign key enforcement is whatever the caller's DSN says — and SQLite's historical default is off, in which case rio.ErrForeignKeyViolated can never happen (see Open).
func Open ¶
Open opens a SQLite database and returns a *rio.DB speaking the rio.SQLite dialect with this package's error translator installed.
Before handing the DSN to modernc.org/sqlite, Open appends the default pragmas described on defaultPragmas — foreign_keys(1) and busy_timeout(5000). A _pragma the DSN already sets is respected, never overridden.
Like database/sql itself, Open validates nothing eagerly: a bad path or DSN surfaces on first use (or on an explicit Ping).
Types ¶
This section is empty.