dbcon

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2020 License: MIT Imports: 6 Imported by: 1

README

dbcon

Package to manage DBs connection with singleton pattern

Documentation

Index

Constants

View Source
const Postgres = "postgres"

Variables

View Source
var ErrExpectedOneRow = errors.New("expected 1 row")

ErrExpectedOneRow is used for indicate that expected 1 row

Functions

func Close

func Close()

Close pool connection

func ExecAffectingOneRow added in v1.1.0

func ExecAffectingOneRow(stmt *sql.Stmt, args ...interface{}) error

func FloatToNull

func FloatToNull(i float64) sql.NullFloat64

FloatToNull returns nil if date has zero value

func GetConnection

func GetConnection() *sql.DB

GetConnection return an unique instance of sql.DB

func GetPsqlConnection

func GetPsqlConnection(config DBConfig) error

func IntToNull

func IntToNull(i int64) sql.NullInt64

IntToNull returns nil if date has zero value

func ParseDateToTime

func ParseDateToTime(s string) pq.NullTime

ParseDateToTime returns nil if date has zero value

func StringToNull

func StringToNull(s string) sql.NullString

StringToNull returns nil if date has zero value

func TimeToNull

func TimeToNull(t time.Time) pq.NullTime

TimeToNull returns nil if date has zero value

Types

type DBConfig

type DBConfig struct {
	Driver   string
	User     string
	Password string
	Server   string
	Port     uint
	DBName   string
	SSLMode  string
}

type RowScanner

type RowScanner interface {
	Scan(dest ...interface{}) error
}

Jump to

Keyboard shortcuts

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