postgres

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2019 License: MIT Imports: 12 Imported by: 0

README

postgres

postgres://user:password@host:port/dbname?query (postgresql:// works, too)

URL Query WithInstance Config Description
dbname DatabaseName The name of the database to connect to
search_path This variable specifies the order in which schemas are searched when an object is referenced by a simple name with no schema specified.
user The user to sign in as
password The user's password
host The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
port The port to bind to. (default is 5432)
fallback_application_name An application_name to fall back to if one isn't provided.
connect_timeout Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
sslcert Cert file location. The file must contain PEM encoded data.
sslkey Key file location. The file must contain PEM encoded data.
sslrootcert The location of the root certificate file. The file must contain PEM encoded data.
sslmode Whether or not to use SSL (disable|require|verify-ca|verify-full)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilConfig      = fmt.Errorf("no config")
	ErrNoDatabaseName = fmt.Errorf("no database name")
	ErrNoSchema       = fmt.Errorf("no schema")
	ErrDatabaseDirty  = fmt.Errorf("database is dirty")
)

Functions

func Register

func Register()

func WithInstance

func WithInstance(instance *sql.DB, config *Config) (database.Driver, error)

Types

type Config

type Config struct {
	DatabaseName string
	SchemaName   string
	URL          string
}

type Postgres

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

func (*Postgres) Begin

func (p *Postgres) Begin() error

func (*Postgres) Close

func (p *Postgres) Close() error

func (*Postgres) Commit

func (p *Postgres) Commit() error

func (*Postgres) Exec

func (p *Postgres) Exec(command io.Reader, params ...interface{}) error

func (*Postgres) ImportCSV

func (p *Postgres) ImportCSV(filePath, schemaName, tableName, delimiter string, header bool) error

func (*Postgres) Open

func (p *Postgres) Open(url string) (database.Driver, error)

func (*Postgres) Rollback

func (p *Postgres) Rollback() error

func (*Postgres) Unlock

func (p *Postgres) Unlock() error

Jump to

Keyboard shortcuts

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