database

package
v0.0.0-...-5b72f62 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAddr        = "localhost:5432"
	DefaultDatabase    = "postgres"
	DefaultUser        = "postgres"
	DefaultPassword    = "postgres"
	DefaultMaxRetries  = 0
	DefaultDialTimeout = 5 * time.Second
	DefaultReadTimeout = 30 * time.Second
)

default values.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Addr        string
	Database    string
	User        string
	Password    string
	MaxRetries  int
	DialTimeout time.Duration
	ReadTimeout time.Duration
}

Config contains database connection options.

type DB

type DB interface {
	// GetTableColumns returns column names for the given table
	GetTableColumns(table string) ([]string, error)

	// GetTableDependencies returns  dependent tables for the given table
	GetTableDependencies(table string) ([]string, error)

	// CopyTo copy data from a table to io.Writer
	CopyTo(w io.Writer, table string) error
}

DB wrapper interface for the postgres database.

func ConnectDB

func ConnectDB(logger log.Logger, cfg *Config) (DB, error)

ConnectDB connects to a database using provided options.

Jump to

Keyboard shortcuts

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