db

package
v1.8.94 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.8.77

type Config struct {
	Host string
	Name string
	User string
	Pass string
}

type IDB

type IDB interface {
	Close()
	Exec(query string, args ...interface{}) (sql.Result, error)
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
	ExecMany(stmts []string, chunkSize int) (e error)
	Host() string // The host name (from config)
	Name() string // The name of the database (from config)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
}

IDB is a container for db interactions

func NewMySQL added in v1.8.78

func NewMySQL(config *Config, log log.ILog) IDB

New returns a new MySQL object

type MySQL added in v1.8.77

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

MySQL is mysql

func (*MySQL) BeginTx added in v1.8.77

func (m *MySQL) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

BeginTx starts a transaction.

The provided context is used until the transaction is committed or rolled back. If the context is canceled, the sql package will roll back the transaction. Tx.Commit will return an error if the context provided to BeginTx is canceled.

The provided TxOptions is optional and may be nil if defaults should be used. If a non-default isolation level is used that the driver doesn't support, an error will be returned.

func (*MySQL) Close added in v1.8.77

func (m *MySQL) Close()

Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.

It is rare to Close a DB, as the DB handle is meant to be long-lived and shared between many goroutines.

func (*MySQL) Exec added in v1.8.77

func (m *MySQL) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*MySQL) ExecMany added in v1.8.77

func (m *MySQL) ExecMany(stmts []string, chunkSize int) (e error)

UpdateMany updates a slice of User objects in chunks

func (*MySQL) Host added in v1.8.77

func (m *MySQL) Host() string

func (*MySQL) Name added in v1.8.77

func (m *MySQL) Name() string

func (*MySQL) Query added in v1.8.78

func (m *MySQL) Query(query string, args ...interface{}) (*sql.Rows, error)

func (*MySQL) QueryRow added in v1.8.84

func (m *MySQL) QueryRow(query string, args ...interface{}) *sql.Row

Jump to

Keyboard shortcuts

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