dbutil

package
v0.28.3-rc-crdb Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNullTime = errs.Class("null time error")

ErrNullTime defines error class for NullTime.

Functions

func BytesToUUID added in v0.28.0

func BytesToUUID(data []byte) (uuid.UUID, error)

BytesToUUID is used to convert []byte to UUID.

func Configure

func Configure(db *sql.DB, mon *monkit.Scope)

Configure Sets Connection Boundaries and adds db_stats monitoring to monkit

Types

type Implementation added in v0.27.0

type Implementation int

Implementation type of valid DBs

const (
	// Unknown is an unknown db type
	Unknown Implementation = iota
	// Postgres is a Postgresdb type
	Postgres
	// Cockroach is a Cockroachdb type
	Cockroach
	// Bolt is a Bolt kv store
	Bolt
	// Redis is a Redis kv store
	Redis
)

func ImplementationForScheme added in v0.27.0

func ImplementationForScheme(scheme string) Implementation

ImplementationForScheme returns the Implementation that is used for the url with the provided scheme.

func SplitConnStr added in v0.27.0

func SplitConnStr(s string) (driver string, source string, implementation Implementation, err error)

SplitConnStr returns the driver and DSN portions of a URL, along with the db implementation.

type NullTime

type NullTime struct {
	time.Time
	Valid bool
}

NullTime time helps convert nil to time.Time.

func (*NullTime) Scan

func (nt *NullTime) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTime) Value

func (nt NullTime) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type TempDatabase added in v0.27.0

type TempDatabase struct {
	*sql.DB
	ConnStr        string
	Schema         string
	Driver         string
	Implementation Implementation
	Cleanup        func(*sql.DB) error
}

TempDatabase is a database (or something that works like an isolated database, such as a PostgreSQL schema) with a semi-unique name which will be cleaned up when closed. Mainly useful for testing purposes.

func (*TempDatabase) Close added in v0.27.0

func (db *TempDatabase) Close() error

Close closes the database and deletes the schema.

Directories

Path Synopsis
Package dbschema package implements querying and comparing schemas for testing.
Package dbschema package implements querying and comparing schemas for testing.
Package pgutil contains utilities for postgres
Package pgutil contains utilities for postgres

Jump to

Keyboard shortcuts

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