sqliteshim

package module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: BSD-2-Clause Imports: 3 Imported by: 88

README

sqliteshim

PkgGoDev

sqliteshim automatically imports modernc.org/sqlite or mattn/go-sqlite3 depending on your platform.

Currently sqliteshim uses packages in the following order:

Otherwise it registers a driver that returns an error on unsupported platforms.

You can install sqliteshim with:

go get github.com/uptrace/bun/driver/sqliteshim

And then create a sql.DB:

sqldb, err := sql.Open(sqliteshim.ShimName, "file::memory:?cache=shared")

Alternatively you can also use sqliteshim.DriverName:

if sqliteshim.HasDriver() {
	sqldb, err := sql.Open(sqliteshim.DriverName(), "file::memory:?cache=shared")
}

Documentation

Overview

Package sqliteshim is a shim package that imports an appropriate sqlite driver for the build target and registers it under ShimName.

Currently it uses packages in the following order:

  • modernc.org/sqlite on supported platforms,
  • github.com/mattn/go-sqlite3 if Cgo is enabled,

Otherwise registers a driver that returns an error on unsupported platforms.

Index

Constants

View Source
const ShimName = "sqliteshim"

ShimName is the name of the shim database/sql driver registration.

Variables

This section is empty.

Functions

func Driver

func Driver() driver.Driver

Driver returns the shim driver registered under ShimName name.

func DriverName

func DriverName() string

DriverName is the name of the database/sql driver. Note that unlike ShimName the value depends on the build target. That is, DriverName returns the name of the underlying database driver.

func HasDriver

func HasDriver() bool

HasDriver indicates that SQLite driver implementation is available.

Types

type UnsupportedError

type UnsupportedError struct{}

UnsupportedError is returned from driver on unsupported platforms.

func (*UnsupportedError) Error

func (e *UnsupportedError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL