driver

package
v2.1.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package driver holds the driver interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Beginner added in v1.3.0

type Beginner interface {
	Begin() (Tx, error)
}

Beginner defines a database that can begin a transaction.

type Conn added in v1.3.0

type Conn interface {
	Databaser
	Beginner
	Close() error
}

Conn interface

type Copy added in v1.3.0

type Copy interface {
	CopyToWriter(w io.Writer, sql string, args ...interface{}) error
	CopyFromReader(r io.Reader, sql string, args ...interface{}) error
}

Copy interface

type CopyConn added in v1.3.0

type CopyConn interface {
	Copy
	Conn
}

CopyConn interface

type Databaser added in v1.3.0

type Databaser interface {
	Execer
	RowQueryer
	Queryer
}

Databaser interface

type Driver

type Driver interface {
	// Creates and returns a connection
	NewConn(url, searchPath string) (conn Conn, err error)

	// SearchPath sets the search path and returns a func that reverts the change
	SearchPath(conn Conn, newSearchPath string) (revert func() error, err error)

	// Ensure the version table exists
	EnsureVersionTable(db Beginner, schema string) (err error)

	// FilenameExtension returns the extension of the migration files.
	// The returned string must not begin with a dot.
	FilenameExtension() string

	// TableName returns the table name used for storing schema migration versions.
	TableName() string

	// Migrate is the heart of the driver.
	// It will receive a file which the driver should apply
	// to its backend or whatever. The migration function should use
	// the pipe channel to return any errors or other useful information.
	Migrate(db Databaser, file *file.Migration, pipe chan interface{})

	// Version returns the current migration version.
	Version(db RowQueryer) (version file.Version, err error)

	// GetMigrationFiles gets all migration files in the schema migrations table
	GetMigrationFiles(db Databaser) (files file.MigrationFiles, err error)

	// UpdateFiles updates the up and down file contents
	UpdateFiles(db Databaser, file *file.Migration, pipe chan interface{})
}

Driver is the interface type that needs to implemented by all drivers.

type DumpDriver added in v1.3.0

type DumpDriver interface {
	Driver
	NewCopyConn(url, searchPath string) (conn CopyConn, err error)
	Dump(conn CopyConn, dw file.DumpWriter, schema string, pipe chan interface{}, handleInterrupts func() chan os.Signal)
	Restore(conn CopyConn, dr file.DumpReader, schema string, pipe chan interface{}, handleInterrupts func() chan os.Signal)
	DeleteSchema(db Execer, schema string) error
	TruncateTables(db Conn, schema string) error
}

DumpDriver interface

type Execer added in v1.3.0

type Execer interface {
	Exec(query string, args ...interface{}) error
}

Execer interface

type Queryer added in v1.3.0

type Queryer interface {
	Query(query string, args ...interface{}) (RowsScanner, error)
}

Queryer defines a database that can perform queries.

type RowQueryer added in v1.3.0

type RowQueryer interface {
	QueryRow(query string, args ...interface{}) Scanner
}

RowQueryer defines a database that can query a row.

type RowsScanner added in v1.3.0

type RowsScanner interface {
	// Columns() ([]string, error)
	Scan(dest ...interface{}) (err error)
	Err() error
	Next() bool
	Close()
}

RowsScanner defines a type that can scan rows returned from a database query.

type Scanner added in v1.3.0

type Scanner interface {
	// Columns() ([]string, error)
	Scan(dest ...interface{}) (err error)
}

Scanner defines a type that can handle basic row scanning from a db query.

type Tx added in v1.3.0

type Tx interface {
	Databaser
	Rollback() error
	Commit() error
}

Tx interface

Directories

Path Synopsis
Package pgx implements the Driver interface.
Package pgx implements the Driver interface.

Jump to

Keyboard shortcuts

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