dbutil

package
v0.0.0-...-3dbc48c Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrForeignTables = fmt.Errorf("the database contains foreign tables")
View Source
var ErrNotOwned = fmt.Errorf("the database is owned by")
View Source
var ErrUnsupportedDatabaseVersion = fmt.Errorf("unsupported database schema version")

Functions

This section is empty.

Types

type ContextExecable

type ContextExecable interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

type Database

type Database struct {
	*sql.DB
	Owner        string
	VersionTable string
	Log          log.Logger
	Dialect      Dialect
	UpgradeTable UpgradeTable

	IgnoreForeignTables       bool
	IgnoreUnsupportedDatabase bool
}

func NewFromConfig

func NewFromConfig(owner string, cfg bridgeconfig.DatabaseConfig, dbLog log.Logger) (*Database, error)

func NewWithDB

func NewWithDB(db *sql.DB, rawDialect string) (*Database, error)

func NewWithDialect

func NewWithDialect(uri, rawDialect string) (*Database, error)

func (*Database) Child

func (db *Database) Child(logName, versionTable string, upgradeTable UpgradeTable) *Database

func (*Database) Upgrade

func (db *Database) Upgrade() error

type Dialect

type Dialect int
const (
	DialectUnknown Dialect = iota
	Postgres
	SQLite
)

func ParseDialect

func ParseDialect(engine string) (Dialect, error)

func (Dialect) String

func (dialect Dialect) String() string

type Execable

type Execable interface {
	ContextExecable
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

type Scannable

type Scannable interface {
	Scan(...interface{}) error
}

type UpgradeTable

type UpgradeTable []upgrade

func (*UpgradeTable) Register

func (ut *UpgradeTable) Register(from, to int, message string, fn upgradeFunc)

func (*UpgradeTable) RegisterFS

func (ut *UpgradeTable) RegisterFS(fs fullFS)

func (*UpgradeTable) RegisterFSPath

func (ut *UpgradeTable) RegisterFSPath(fs fullFS, dir string)

type Upgrader

type Upgrader struct {
	*sql.DB
	Log     log.Logger
	Dialect Dialect
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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