sqldb

package
v2.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresConfig

type PostgresConfig struct {
	Hostname     string
	Port         string
	Username     string
	Password     string
	DatabaseName string
}

PostgresConfig contains the Postgres database configuration arguments

func (*PostgresConfig) Name

func (c *PostgresConfig) Name() string

Name is used by the settings library to replace the default naming convention.

type PostgresConfigComponent

type PostgresConfigComponent struct{}

PostgresConfigComponent satisfies the settings library Component API, and may be used by the settings.NewComponent function.

func (*PostgresConfigComponent) New

New constructs a DB from a config

func (*PostgresConfigComponent) Settings

Settings populates a set of defaults if none are provided via config.

type PostgresDB

type PostgresDB struct {
	// contains filtered or unexported fields
}

PostgresDB is a SQLDB implementation that uses a PostgreSQL database connection pool.

func (*PostgresDB) Conn

func (db *PostgresDB) Conn() *sql.DB

Conn returns the currently initialized and open DB connection if one exists, or nil

func (*PostgresDB) Init

func (db *PostgresDB) Init(ctx context.Context, host, port, username, password, dbname string) error

Init initializes a connection to a Postgres database according to the environment variables POSTGRES_HOST, POSTGRES_PORT, POSTGRES_USER, POSTGRES_PASSWORD, POSTGRES_DATABASE

func (*PostgresDB) RunScript

func (db *PostgresDB) RunScript(ctx context.Context, name string) error

RunScript executes a SQL script from disk against the database.

func (*PostgresDB) Use

func (db *PostgresDB) Use(ctx context.Context, psqlInfo string) error

Use closes any existing database connection, then opens, pings, and sets a new one based on the connection string provided in format: "host=%s port=%s user=%s password=%s dbname=%s sslmode=%s"

Jump to

Keyboard shortcuts

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