sqldb

package module
v0.0.0-...-73b7fe6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 8 Imported by: 0

README

sqldb

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Params

type Params struct {
	DSN             string
	Server          string
	Host            string
	Port            string
	Username        string
	Password        string
	Database        string
	MaxCap          *int
	MaxIdle         *int
	ConnMaxLifetime *int
	MaxRetries      *int
	RetriesInterval *int
	RetryableErrors []string
}

type Sql

type Sql interface {
	DB() *sqlx.DB
	Ping() error
	CreateTx() (*sqlx.Tx, error)
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	NamedExec(query string, arg interface{}) (sql.Result, error)
	NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
	Select(dest interface{}, query string, args ...interface{}) error
}

func DB

func DB(param Params) (db Sql, err error)

type SqlTx

type SqlTx interface {
	NamedExec(query string, arg interface{}) (sql.Result, error)
	NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
	Commit() error
	Rollback() error
}

func Tx

func Tx(param Params) (tx SqlTx, err error)

Creates new transaction object every time

Jump to

Keyboard shortcuts

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