Back to godoc.org

Package postgresql

v0.1.2
Latest Go to latest

The highest tagged major version is .

Published: Mar 30, 2018 | License: Apache-2.0 | Module: github.com/NYTimes/gizmo

Index

Constants

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

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

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier