postgresql

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSSLMode is verify-full
	DefaultSSLMode = "verify-full"
	// DefaultPort is the default post for Postgresql connections
	DefaultPort = 5432
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	User    string `envconfig:"POSTGRESQL_USER"`
	Pw      string `envconfig:"POSTGRESQL_PW"`
	Host    string `envconfig:"POSTGRESQL_HOST_NAME"`
	Port    int    `envconfig:"POSTGRESQL_PORT"`
	DBName  string `envconfig:"POSTGRESQL_DB_NAME"`
	SSLMode string `envconfig:"POSTGRESQL_SSL_MODE"`
}

Config holds everything you need to connect and interact with a PostgreSQL DB.

func LoadConfigFromEnv

func LoadConfigFromEnv() *Config

LoadConfigFromEnv will attempt to load a Postgresql object from environment variables. If not populated, nil is returned

func (*Config) DB

func (p *Config) DB() (*sql.DB, error)

DB will open a sql connection. Users must import a postgresql driver in their main to use this.

func (*Config) String

func (p *Config) String() string

String will return the Postgresql connection string

Jump to

Keyboard shortcuts

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