db

package
v0.0.0-...-8aa1adc Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

RO this db can only be used for read-only calls. Calls made that trigger a RW will break replication if successful but also should actually produce an error from mysql.

RW this db is used for read-write calls, it can be used for RO calls too but to load balance use the RO please.

Functions

func Init

func Init(dsnRO, dsnRW string, debug bool) error

Init initializes a database connection based on the dsn provided. It also sets it as the global db connection.

func WithTx

func WithTx(exec boil.Executor, currentTx boil.Transactor, f TxFunc) (err error)

WithTx wraps a function in an sql transaction. the transaction is committed if there's no error, or rolled back if there is one. if `currentTx` is nil, a new transaction is started. otherwise currentTx is used as the transaction

Types

type QueryLogger

type QueryLogger struct {
	DB      *sqlx.DB
	Logger  *log.Logger
	Enabled bool
	Name    string
}

QueryLogger is used to add extended logging for db queries in debug mode.

func (*QueryLogger) Begin

func (d *QueryLogger) Begin() (boil.Transactor, error)

Begin implementation of Executor

func (*QueryLogger) Close

func (d *QueryLogger) Close() error

Close implementation of Executor

func (*QueryLogger) Exec

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

Exec implementation of Executor

func (*QueryLogger) Query

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

Query implementation of Executor

func (*QueryLogger) QueryRow

func (d *QueryLogger) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow implementation of Executor

type TxFunc

type TxFunc func(tx boil.Transactor) error

TxFunc is a function that can be wrapped in a transaction

Jump to

Keyboard shortcuts

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