dbal

package
v0.0.549 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 7 Imported by: 21

Documentation

Index

Constants

View Source
const (
	// DriverMySQL is the mysql driver name.
	DriverMySQL = "mysql"

	// DriverPostgreSQL is the postgres driver name.
	DriverPostgreSQL = "postgres"

	// DriverCockroachDB is the cockroach driver name.
	DriverCockroachDB = "cockroach"

	// UnknownDriver is the driver name if the driver is unknown.
	UnknownDriver = "unknown"
)
View Source
const (
	// SQLiteInMemory is a DNS string for SQLite in-memory database.
	//
	// DEPRECATED: Do not use this DSN string as it can cause flaky tests
	// due to the way SQL connection pooling works. Please use NewSQLiteTestDatabase instead.
	SQLiteInMemory = "sqlite://file::memory:?_fk=true"
	// SQLiteSharedInMemory is a DNS string for SQLite in-memory database in shared mode.
	//
	// DEPRECATED: Do not use this DSN string as it can cause flaky tests
	// due to the way SQL connection pooling works. Please use NewSQLiteTestDatabase instead.
	SQLiteSharedInMemory = "sqlite://file::memory:?_fk=true&cache=shared"
)

Variables

View Source
var (

	// ErrNoResponsibleDriverFound is returned when no driver was found for the provided DSN.
	ErrNoResponsibleDriverFound = errors.New("dsn value requested an unknown driver")
	ErrSQLiteSupportMissing     = errors.New(`the DSN connection string looks like a SQLite connection, but SQLite support was not built into the binary. Please check if you have downloaded the correct binary or are using the correct Docker Image. Binary archives and Docker Images indicate SQLite support by appending the -sqlite suffix`)
)

Functions

func Canonicalize added in v0.0.22

func Canonicalize(database string) string

Canonicalize returns constants DriverMySQL, DriverPostgreSQL, DriverCockroachDB, UnknownDriver, depending on `database`.

func IsMemorySQLite added in v0.0.207

func IsMemorySQLite(dsn string) bool

IsMemorySQLite returns true if a given DSN string is pointing to a SQLite database.

SQLite can be written in different styles depending on the use case - just in memory - shared connection - shared but unique in the same process see: https://sqlite.org/inmemorydb.html

func IsSQLite added in v0.0.166

func IsSQLite(dsn string) bool

IsSQLite returns true if the connection is a SQLite string.

func MustCanonicalize added in v0.0.22

func MustCanonicalize(database string) string

MustCanonicalize returns constants DriverMySQL, DriverPostgreSQL, DriverCockroachDB or fatals.

func NewSQLiteInMemoryDatabase added in v0.0.387

func NewSQLiteInMemoryDatabase(name string) string

NewSQLiteInMemoryDatabase creates a new unique SQLite database which is shared amongst all callers and identified by an individual file name.

func NewSQLiteTestDatabase added in v0.0.371

func NewSQLiteTestDatabase(t interface {
	TempDir() string
}) string

NewSQLiteTestDatabase creates a new unique SQLite database which is shared amongst all callers and identified by an individual file name.

func NewSharedUniqueInMemorySQLiteDatabase added in v0.0.365

func NewSharedUniqueInMemorySQLiteDatabase() (string, error)

NewSharedUniqueInMemorySQLiteDatabase creates a new unique SQLite database which is shared amongst all callers and identified by an individual file name.

DEPRECATED: Please use NewSQLiteTestDatabase instead.

func RegisterDriver added in v0.0.37

func RegisterDriver(d func() Driver)

RegisterDriver registers a driver

Types

type Driver added in v0.0.37

type Driver interface {
	// CanHandle returns true if the driver is capable of handling the given DSN or false otherwise.
	CanHandle(dsn string) bool

	// Ping returns nil if the driver has connectivity and is healthy or an error otherwise.
	Ping() error
}

Driver represents a driver

func GetDriverFor added in v0.0.37

func GetDriverFor(dsn string) (Driver, error)

GetDriverFor returns a driver for the given DSN or ErrNoResponsibleDriverFound if no driver was found.

Jump to

Keyboard shortcuts

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