mariadb

package module
v0.0.0-...-fc32900 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	UserName        *string
	Password        *string
	Server          *string
	DBName          *string
	DBDSN           *string
	MaxCap          *int
	MaxIdle         *int
	ConnMaxLifetime *int
	MaxRetries      *int
	RetriesInterval *int
	RetryableErrors []string
)

Functions

This section is empty.

Types

type Pool

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

func (Pool) CreateTx

func (p Pool) CreateTx() (sqlTx *sqlx.Tx, err error)

func (Pool) DB

func (p Pool) DB() *sqlx.DB

func (Pool) Exec

func (p Pool) Exec(query string, args ...interface{}) (res sql.Result, err error)

func (Pool) NamedExec

func (p Pool) NamedExec(query string, arg interface{}) (res sql.Result, err error)

func (Pool) NamedQuery

func (p Pool) NamedQuery(query string, arg interface{}) (res *sqlx.Rows, err error)

func (Pool) Ping

func (p Pool) Ping() (err error)

func (Pool) Query

func (p Pool) Query(query string, args ...interface{}) (res *sql.Rows, err error)

func (Pool) Select

func (p Pool) Select(dest interface{}, query string, args ...interface{}) (err error)

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() (pool Sql, err error)

Creates new if already not created

func NewPool

func NewPool(dsn string, maxRetries, maxOpenConn, maxIdle int, connMaxLifeTime, retriesInterval time.Duration, retryableErros []string) (Sql, 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 NewTransaction

func NewTransaction(tx *sqlx.Tx, maxRetries int, retriesInterval time.Duration, retryableErros []string) SqlTx

func Tx

func Tx() (tx SqlTx, err error)

Creates new transaction object every time

type Transaction

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

func (Transaction) Commit

func (p Transaction) Commit() (err error)

func (Transaction) NamedExec

func (p Transaction) NamedExec(query string, arg interface{}) (res sql.Result, err error)

func (Transaction) NamedQuery

func (p Transaction) NamedQuery(query string, arg interface{}) (res *sqlx.Rows, err error)

func (Transaction) Rollback

func (p Transaction) Rollback() (err error)

Jump to

Keyboard shortcuts

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