main
v1.64.0
modernc.org/sqlite/examples/connector
Documentation
pkg.go.dev ↗Command connector demonstrates sqlite.NewConnector: opening a database through database/sql's sql.OpenDB instead of sql.Open, and interposing on the physical connections database/sql opens.
The interposing is the reason the API exists. sql.Open reaches the driver only by its registered name, so a library wanting to wrap connections has to call sql.Register with a name of its own -- which is process-global, panics on a name it has already seen, and cannot be undone, so the name must be made unique per configuration. sql.OpenDB takes the connector directly and registers nothing.
Usage:
go run ./examples/connector