db

package
v0.0.0-...-1da8f5c Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimeoutSleepSecond = 3
)

Variables

View Source
var (
	ErrTxClosed = errors.New("tx already commit or rollback")
)

Functions

This section is empty.

Types

type ConnectFunc

type ConnectFunc func() (string, string, string)

func ConnectFuncMysql

func ConnectFuncMysql(addr, port, id, pw, dbName string) ConnectFunc

func ConnectFuncPostgres

func ConnectFuncPostgres(addr, port, id, pw, dbName string) ConnectFunc

func ConnectFuncSqlite3

func ConnectFuncSqlite3(dbName string) ConnectFunc

type DB

type DB struct {
	DriverName string
	Dsn        string
	DbName     string
	// contains filtered or unexported fields
}

func NewDB

func NewDB(timeout int, conn ConnectFunc) (db *DB, err error)

func (*DB) Close

func (t *DB) Close() error

func (*DB) Job

func (t *DB) Job() *Job

func (*DB) Raw

func (t *DB) Raw() *sql.DB

func (*DB) SetOpenConns

func (t *DB) SetOpenConns(openConns, idleConns int)

func (*DB) TxJob

func (t *DB) TxJob(isoLevel sql.IsolationLevel, readonly bool) (tx *Tx, err error)

func (*DB) TxJobFunc

func (t *DB) TxJobFunc(isoLevel sql.IsolationLevel, readonly bool, fn func(*Tx) error) (err error)

type Job

type Job struct {
	*gen.Queries
	// contains filtered or unexported fields
}

func NewJob

func NewJob(db *sql.DB) *Job

non-tx job

type Tx

type Tx struct {
	*gen.Queries
	// contains filtered or unexported fields
}

func NewTx

func NewTx(db *sql.DB, isoLevel sql.IsolationLevel, readOnly bool) (*Tx, error)

tx job

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Rollback

func (t *Tx) Rollback() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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