mysqldb

package
v0.0.0-...-b8d2545 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MysqlDriver defines the name of the mysql driver
	MysqlDriver = "mysql"
	// Percent defines the symbol that can be used to simplify the query statement building
	//  for example, when using fmt.Sprintf(), using this variable will avoid issue with double % inside the print
	Percent = "%"
	// NoRow defines the error string when no record found in the query result
	NoRow = "sql: no rows in result set"
)

Variables

This section is empty.

Functions

func DbConnect

func DbConnect(log *logger.Logger, conf config.DbMySQL) (*sqlx.DB, error)

DbConnect opens MySQL database connection

Types

type DbQuery

type DbQuery struct {
	Q string `json:"query"`
}

DbQuery defines the query parameter

it is used to wrap query param and

type QueryArgs

type QueryArgs struct {
	Query string      `db:"query"`
	Args  interface{} `db:"args"`
}

QueryArgs defines the query arguments

it will be used for building each query for the Named Query Execution

type Storage

type Storage struct {
	Db  *sqlx.DB
	Log *logger.Logger
}

func (*Storage) Exec

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

Exec executes a single query with a transaction

func (*Storage) ExecMany

func (d *Storage) ExecMany(qArgsList []QueryArgs) error

ExecMany executes multiple queries with a transaction

func (*Storage) NamedExec

func (d *Storage) NamedExec(qArgs QueryArgs) (*sql.Result, error)

NamedExec executes a single query with a transaction

func (*Storage) Queryx

func (d *Storage) Queryx(query string, args interface{}) (*sqlx.Rows, error)

Queryx executes query

Jump to

Keyboard shortcuts

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