sqlex

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNilPtrValue            = errors.New("nil ptr value")
	ErrPtrValueMustBeAPointer = errors.New("ptr value must be a pointer")
)

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
}

func (*DB) BeginTx

func (db *DB) BeginTx(ctx context.Context, opts *sql.TxOptions) (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 (*DB) Close

func (db *DB) Close() error

func (*DB) ExecContext

func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (Result, error)

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

func (*DB) QueryContext

func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

type Result

type Result interface {
	sql.Result
}

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...any) error
	Err() error
	Close() error
}

type RowsWithSQLRows

type RowsWithSQLRows struct {
	*sql.Rows
}

func NewRowsWithSQLRows

func NewRowsWithSQLRows(rows *sql.Rows) *RowsWithSQLRows

type RowsWithSlice

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

func NewRowsWithSlice

func NewRowsWithSlice(rows []interface{}) *RowsWithSlice

func (*RowsWithSlice) Close

func (v *RowsWithSlice) Close() error

func (*RowsWithSlice) Err

func (v *RowsWithSlice) Err() error

func (*RowsWithSlice) Next

func (v *RowsWithSlice) Next() bool

func (*RowsWithSlice) Scan

func (v *RowsWithSlice) Scan(dest ...any) error

type Stmt

type Stmt interface {
	ExecContext(ctx context.Context, args ...any) (Result, error)
}

type Tx

type Tx interface {
	Rollback() error
	Commit() error
	ExecContext(ctx context.Context, query string, args ...any) (Result, error)
	PrepareContext(ctx context.Context, query string) (Stmt, error)
}

func NewTx

func NewTx(tx *sql.Tx) Tx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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