README

SQLEX

Build Status Coverage Status Go.Dev reference Go Report Card Release

SQLEX is extensions for database/sql and jmoiron/sqlx.

Transaction

sqlex.Transact(db, func(tx *sql.Tx) error {
    return nil
})

sqlex.TransactContext(ctx, txOpts, db, func(tx *sql.Tx) error {
    return nil
})

sqlex.Transactx(db, func(tx *sqlx.Tx) error {
    return nil
})

sqlex.TransactContext(ctx, txOpts, db, func(tx *sqlx.Tx) error {
    return nil
})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(ctx context.Context, e Execer, query string, args ...interface{}) (sql.Result, error)

    Exec equals to sqlx.Execer.Exec and sqlx.ExecerContext.ExecContext.

    func Get

    func Get(ctx context.Context, q Queryer, dest interface{}, query string, args ...interface{}) error

      Get equals to sqlx.Get and sqlx.GetContext.

      func MustExec

      func MustExec(ctx context.Context, e Execer, query string, args ...interface{}) sql.Result

        MustExec equals to sqlx.MustExec and sqlx.MustExecContext.

        func NamedExec

        func NamedExec(ctx context.Context, e Ext, query string, arg interface{}) (sql.Result, error)

          NamedExec equals to sqlx.NamedExec and sqlx.NamedExecContext.

          func NamedQuery

          func NamedQuery(ctx context.Context, e Ext, query string, arg interface{}) (*sqlx.Rows, error)

            NamedQuery equals to sqlx.NamedQuery and sqlx.NamedQueryContext.

            func Query

            func Query(ctx context.Context, q Queryer, query string, args ...interface{}) (*sql.Rows, error)

              Query equals to sqlx.Queryer.Query and sqlx.QueryerContext.QueryContext.

              func QueryRowx

              func QueryRowx(ctx context.Context, q Queryer, query string, args ...interface{}) *sqlx.Row

                QueryRowx equals to sqlx.Queryer.QueryRowx and sqlx.QueryerContext.QueryRowxContext.

                func Queryx

                func Queryx(ctx context.Context, q Queryer, query string, args ...interface{}) (*sqlx.Rows, error)

                  Queryx equals to sqlx.Queryer.Queryx and sqlx.QueryerContext.QueryxContext.

                  func Select

                  func Select(ctx context.Context, q Queryer, dest interface{}, query string, args ...interface{}) error

                    Select equals to sqlx.Select and sqlx.SelectContext.

                    func Transact

                    func Transact(db DB, fn func(tx *sql.Tx) error) (err error)

                      Transact begins a transaction, and then invokes fn. Rollback automatically if receives a panic or error.

                      func TransactContext

                      func TransactContext(ctx context.Context, opts *sql.TxOptions, db DB, fn func(ctx context.Context, tx *sql.Tx) error) (err error)

                        TransactContext begins a transaction, and then invokes fn. Rollback automatically if receives a panic or error.

                        func TransactContextx

                        func TransactContextx(ctx context.Context, opts *sql.TxOptions, db DBx, fn func(ctx context.Context, tx *sqlx.Tx) error) (err error)

                          TransactContextx begins a transaction, and then invokes fn. Rollback automatically if receives a panic or error.

                          func Transactx

                          func Transactx(db DBx, fn func(tx *sqlx.Tx) error) (err error)

                            Transactx begins a transaction, and then invokes fn. Rollback automatically if receives a panic or error.

                            Types

                            type DB

                            type DB interface {
                            	Begin() (*sql.Tx, error)
                            	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
                            }

                              DB is an interface for sql.DB and sqlx.DB.

                              type DBx

                              type DBx interface {
                              	DB
                              	Beginx() (*sqlx.Tx, error)
                              	BeginTxx(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)
                              }

                                DBx is an interface for sqlx.DB.

                                type Execer

                                type Execer interface {
                                	sqlx.Execer
                                	sqlx.ExecerContext
                                }

                                  Execer is an interface that wraps sqlx.Execer and sqlx.ExecerContext.

                                  type Ext

                                  type Ext interface {
                                  	Execer
                                  	Queryer
                                  	DriverName() string
                                  	Rebind(string) string
                                  	BindNamed(string, interface{}) (string, []interface{}, error)
                                  }

                                    Ext is an interface that wraps sqlx.Ext and sqlx.ExtContext.

                                    type Queryer

                                    type Queryer interface {
                                    	sqlx.Queryer
                                    	sqlx.QueryerContext
                                    }

                                      Queryer is an interface that wraps sqlx.Queryer and sqlx.QueryerContext.