Documentation
¶
Overview ¶
Package adbcbridge loads adbcbridge -- the ADBC-over-ODBC driver built as libadbc_driver_odbc.so / .dylib / .dll -- through the ADBC Go driver manager.
The package is a thin layer over github.com/apache/arrow-adbc/go/adbc/drivermgr: it finds the shared library (DriverPath), hands its path to the driver manager (NewDriver) and fills in the ODBC connection string (Open). Everything past that -- adbc.Database, adbc.Connection, adbc.Statement -- is the ordinary ADBC Go API.
The driver manager is cgo: building this package needs a C compiler (on Windows a GCC such as mingw-w64, with CGO_ENABLED=1).
The shared library itself is not part of the module. It comes from install.sh or `cmake --install` in a checkout of the driver, from a release binary, or from the ADBC driver manifest named "odbc"; see DriverPath for the lookup order. Building with `-tags adbcbridge_embed` embeds a copy placed in internal/native/<goos>_<goarch>/ into the binary instead.
Index ¶
Constants ¶
const Embedded = false
Embedded reports whether this build carries (or at least looks for) an embedded copy of the driver: false without -tags adbcbridge_embed.
const EnvDriver = "ADBC_ODBC_DRIVER"
EnvDriver is the environment variable DriverPath checks first: the path of the adbcbridge shared library, as the rest of the repository (tests, benchmarks, the Python package) spells it.
const EnvLibrary = "ADBCBRIDGE_LIBRARY"
EnvLibrary is the second environment variable DriverPath checks, the package-specific spelling of the same thing.
const EnvManifestPath = "ADBC_DRIVER_PATH"
EnvManifestPath is the ADBC driver manager's own search-path variable: a list of directories, separated by os.PathListSeparator, holding driver manifests such as odbc.toml.
const ManifestName = "odbc.toml"
ManifestName is the file name of the ADBC driver manifest that names the driver "odbc", as written by install.sh / cmake --install.
const OptionKeyDriver = "driver"
OptionKeyDriver is the drivermgr option naming the shared library to load.
const OptionKeyURI = "uri"
OptionKeyURI is the option carrying the ODBC connection string ("Driver=...;Database=...;" or "DSN=...;").
Variables ¶
This section is empty.
Functions ¶
func DriverPath ¶
DriverPath returns the absolute path of the adbcbridge shared library.
It is looked for, in order, in
- the ADBC_ODBC_DRIVER environment variable, then ADBCBRIDGE_LIBRARY: an explicit value that does not exist is an error, not a silent fallback;
- the copy embedded in the binary, when built with -tags adbcbridge_embed (extracted to the user cache directory on first use);
- the ADBC driver manifest named "odbc" (odbc.toml) in the directories the ADBC driver manager searches: $ADBC_DRIVER_PATH, the user directory (~/.config/adbc/drivers, ~/Library/Application Support/ADBC/Drivers, %LOCALAPPDATA%\ADBC\Drivers), /etc/adbc/drivers and friends, plus $VIRTUAL_ENV and $CONDA_PREFIX prefixes;
- common install locations (/usr/local/lib, /usr/lib, /opt/adbcbridge/lib, /opt/homebrew/lib, /usr/lib/<arch>-linux-gnu, %ProgramFiles%\adbcbridge, the lib directories of $VIRTUAL_ENV / $CONDA_PREFIX) and a CMake build/ tree next to a source checkout of this package.
The error is a *DriverNotFoundError listing everything that was tried.
func NewDriver ¶
NewDriver resolves the adbcbridge shared library with DriverPath and returns an adbc.Driver (concretely a *Driver) whose NewDatabase loads it.
alloc is the allocator ADBC Go drivers conventionally take; drivermgr v1.8.0 imports Arrow data through the C Data Interface and takes no allocator, so it is kept only for API parity (see Driver.Allocator). nil selects memory.DefaultAllocator.
func Open ¶
func Open(ctx context.Context, alloc memory.Allocator, connectionString string, options map[string]string) (adbc.Database, error)
Open creates an adbc.Database for connectionString, an ODBC connection string such as "Driver=SQLite3;Database=my.db;" or "DSN=mydsn;". options are extra database options ("adbc.odbc.delegate", "adbc.odbc.prefetch", ...); the connection string is stored under "uri" and wins over any "uri" in options.
The database is initialised but not connected: call Open on the result to get an adbc.Connection, and Close it when done.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is an adbc.Driver that loads adbcbridge through the ADBC driver manager. Its NewDatabase adds the resolved library path under the "driver" key and otherwise passes the options to drivermgr.Driver unchanged.
Get one from NewDriver; the zero value is not usable.
func (*Driver) NewDatabase ¶
NewDatabase creates an adbc.Database backed by the adbcbridge library.
opts are drivermgr / driver options: "uri" carries the ODBC connection string, and the driver's own keys ("adbc.odbc.*") go straight through. The resolved library path is added under "driver"; a caller-supplied "driver" option is left alone, so a specific library can still be forced per database.
type DriverNotFoundError ¶
type DriverNotFoundError struct {
// Library is the file name looked for on this OS
// (libadbc_driver_odbc.so, libadbc_driver_odbc.dylib, adbc_driver_odbc.dll).
Library string
// Searched lists, in order, every place that was checked, each with a
// short note on why it did not yield the library.
Searched []string
}
DriverNotFoundError is returned by DriverPath (and so by NewDriver and Open) when no adbcbridge shared library can be found.
func (*DriverNotFoundError) Error ¶
func (e *DriverNotFoundError) Error() string