pqsql

package module
v0.0.0-...-453ee4b Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: MIT Imports: 6 Imported by: 0

README

pqsql

golang postgres driver with migrations base on https://github.com/lib/pq

Build Status

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseAfter

func CloseAfter(rows io.Closer, process func() error) error

CloseAfter

func MigrationsUp

func MigrationsUp(ctx context.Context, db *sql.DB, src *Migrations) error

MigrationsUp

func Open

func Open(ctx context.Context, cfg *Config) (*sql.DB, error)

Open represent connect to database function

Types

type Config

type Config struct {
	Address  string
	Database string
	Username string
	Password string

	MaxOpenConn int
	MaxIdleConn int
	MaxConnTTL  time.Duration
}

Config represent postgres configuration

func (*Config) TuneConnPool

func (cfg *Config) TuneConnPool(p interface {
	SetMaxOpenConns(int)
	SetMaxIdleConns(int)
	SetConnMaxLifetime(time.Duration)
})

TuneConnPool tune configuration for database connector

func (*Config) URI

func (cfg *Config) URI() string

URI return credential string

type Migration

type Migration struct {
	ID   string
	Up   []string
	Down []string
}

Migration represent one migration step

type Migrations

type Migrations struct {
	Table  string
	Source []*Migration
}

Migrations represent migrations source

Jump to

Keyboard shortcuts

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