Write a driver

A tobira driver teaches tobira one database. It is Go code that implements the driver contract, tested with the drivertest conformance kit. You can ship it two ways: as a Go module compiled into the tobira binary, or as an external plugin, a separate tobira-driver-<name> program that tobira starts and talks to over gRPC. Each built-in driver is its own Go module, so a database SDK reaches a build only when that driver is used.

Quick start

Start from one of the runnable examples:

func init() { driver.Register(New()) }        // a driver module

func main() { sdk.Serve(memdemo.New()) }       // a plugin

In this section

PageCovers
Driver moduleImplementing Driver and Conn, registering, adding capabilities, and the checklist for a built-in driver
Conformance kitRunning drivertest, kind fixtures, storage limits and the other fixture options
External pluginServing, testing, installing and using a plugin, its trust model and limits
Plugin protocolThe stable api package, the Go SDK, the host and the wire protocol

Which route to choose

Driver moduleExternal plugin
Ships inthe tobira binaryits own binary
Change to tobira neededyes (a blank import in cmd/tobira)none
LanguagesGoGo, or any language that speaks gRPC
cgono (tobira’s releases are built without cgo)yes
Installcomes with tobiratobira driver install <url|path> --sha256 <hex>

External plugin

An external plugin is a tobira-driver-<name> binary in the plugins directory or on PATH. tobira starts it when a connection first needs it. To the terminal UI, the CLI, the AI assistant and the MCP server it is one more driver: a connection with dsn: <name>:// uses it.

go build -o tobira-driver-memdemo .
# Linux:
tobira driver install ./tobira-driver-memdemo --sha256 "$(sha256sum tobira-driver-memdemo | cut -d' ' -f1)"
# macOS:
tobira driver install ./tobira-driver-memdemo --sha256 "$(shasum -a 256 tobira-driver-memdemo | cut -d' ' -f1)"
tobira driver info memdemo

tobira driver install requires the binary’s sha256 and never runs the binary. The steps, the trust model and the limits are on External plugin.