Documentation
¶
Overview ¶
Package sqlitepure adapts the pure-Go SQLite driver modernc.org/sqlite to momo. It needs no cgo and no C toolchain and builds on every platform Go targets, Windows included. It has no vector support: Capabilities reports Vectors=false and a statement that calls an sqlite-vec function fails with momo.ErrUnsupported. Use driver/sqlitedriver for vectors.
The package does not import driver/sqlitedriver, so a build that uses it never links mattn/go-sqlite3 or sqlite-vec. Config is the same type as sqlitedriver.Config.
Open uses the database/sql driver name "sqlite", which modernc registers when it is imported, and so does not register anything of its own. The package adds no process-wide hook: every setting travels in the DSN.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassifyError ¶
ClassifyError maps a modernc *sqlite.Error to *momo.Error. Other errors, and errors that are already *momo.Error, are returned unchanged. SQLite messages name tables and columns and never carry row values, so the message is safe to render; the *sqlite.Error stays reachable through errors.As.
Besides result codes there is one message-based rule that is specific to this driver: a message containing "no such function: vec_" is momo.ErrUnsupported, because this driver is built without sqlite-vec. A constraint failure reported with the bare SQLITE_CONSTRAINT code instead of an extended one is classified by its message prefix.
func Open ¶
Open opens a SQLite database with modernc.org/sqlite. The caller owns the returned *sql.DB. Open pings the database and checks that the bundled SQLite is at least 3.35.0, so a refused connection is reported here.
dsn is a file path or a "file:" URI. The query string may carry only _txlock, mode and cache; the transaction lock in it overrides cfg. This allowlist is narrower than the one of sqlitedriver (mattn): _busy_timeout, _timeout, _loc and _cache_size are refused here, and the busy timeout comes from cfg.BusyTimeout alone. The busy timeout, journal mode, synchronous and foreign keys always come from cfg and the adapter, so a DSN cannot switch them off, and a "_pragma" parameter is refused for the same reason. The mode and cache parameters are SQLite URI parameters, which SQLite sees only for a "file:" DSN, so any other DSN carrying them is refused. mode=ro cannot open a database that is not in WAL mode yet, because the adapter sets journal_mode=WAL on every connection: create the database read-write first. An in-memory database with MaxOpenConns above 1 needs cache=shared, and then a statement can fail with SQLITE_LOCKED, which ClassifyError reports as momo.ErrBusy.
Types ¶
type Config ¶
type Config = sqliteconf.Config
Config holds the recommended SQLite settings. It is the same type as sqlitedriver.Config; see that type for the defaults.