sql

package module
v1.0.0-alpha-27a788426... Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

README

gosql

Documentation

Index

Constants

View Source
const (
	LevelDefault         = sql.LevelDefault
	LevelReadUncommitted = sql.LevelReadUncommitted
	LevelReadCommitted   = sql.LevelReadCommitted
	LevelWriteCommitted  = sql.LevelWriteCommitted
	LevelRepeatableRead  = sql.LevelRepeatableRead
	LevelSnapshot        = sql.LevelSnapshot
	LevelSerializable    = sql.LevelSerializable
	LevelLinearizable    = sql.LevelLinearizable
)

Variables

This section is empty.

Functions

func AtP

func AtP(index int) string

func Colon

func Colon(index int) string

func Configure

func Configure(f func(Config) Config)

func Dollar

func Dollar(index int) string

func PanicOnLogicalError

func PanicOnLogicalError(err error)

func PrintLogicalError

func PrintLogicalError(err error)

func Question

func Question(index int) string

Types

type Config

type Config struct {
	Placeholder         Placeholder
	LogicalErrorHandler func(err error)
}

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

func Open

func Open(driverName string, dataSource string) (db *DB, err error)

func OpenDB

func OpenDB(conn driver.Connector) (db *DB)

func (*DB) BeginTx

func (d *DB) BeginTx(ctx context.Context, options *TxOptions) (txCtx context.Context, err error)

func (*DB) CommitTx

func (d *DB) CommitTx(ctx context.Context) (err error)

func (*DB) EndTx

func (d *DB) EndTx(ctx context.Context, txErr error) (commitErr error, rollbackErr error)

func (*DB) Executor

func (d *DB) Executor(ctx context.Context) (executor Executor)

func (*DB) NamedExec

func (d *DB) NamedExec(query string, args map[string]any) (result Result, err error)

func (*DB) NamedExecContext

func (d *DB) NamedExecContext(ctx context.Context, query string, args map[string]any) (result Result, err error)

func (*DB) NamedQuery

func (d *DB) NamedQuery(query string, args map[string]any) (rows *Rows, err error)

func (*DB) NamedQueryContext

func (d *DB) NamedQueryContext(ctx context.Context, query string, args map[string]any) (rows *Rows, err error)

func (*DB) NamedQueryRow

func (d *DB) NamedQueryRow(query string, args map[string]any) (row *Row)

func (*DB) NamedQueryRowContext

func (d *DB) NamedQueryRowContext(ctx context.Context, query string, args map[string]any) (row *Row)

func (*DB) RollbackTx

func (d *DB) RollbackTx(ctx context.Context) (err error)

func (*DB) Transactional

func (d *DB) Transactional(
	ctx context.Context,
	f func(ctx context.Context) error,
	options *TxOptions,
) (beginErr error, err error, commitErr error, rollbackErr error)

func (*DB) TxFromContext

func (d *DB) TxFromContext(ctx context.Context) (tx *Tx, found bool)

type Executor

type Executor interface {
	Exec(query string, args ...any) (result Result, err error)
	NamedExec(query string, args map[string]any) (result Result, err error)

	ExecContext(ctx context.Context, query string, args ...any) (result Result, err error)
	NamedExecContext(ctx context.Context, query string, args map[string]any) (result Result, err error)

	Query(query string, args ...any) (rows *Rows, err error)
	NamedQuery(query string, args map[string]any) (rows *Rows, err error)

	QueryContext(ctx context.Context, query string, args ...any) (rows *Rows, err error)
	NamedQueryContext(ctx context.Context, query string, args map[string]any) (rows *Rows, err error)

	QueryRow(query string, args ...any) (row *Row)
	NamedQueryRow(query string, args map[string]any) (row *Row)

	QueryRowContext(ctx context.Context, query string, args ...any) (row *Row)
	NamedQueryRowContext(ctx context.Context, query string, args map[string]any) (row *Row)
}

type Frame

type Frame uintptr

func (Frame) File

func (f Frame) File() string

func (Frame) Func

func (f Frame) Func() string

func (Frame) Line

func (f Frame) Line() int

type Placeholder

type Placeholder = func(index int) string

type Result

type Result = sql.Result

type Row

type Row = sql.Row

type Rows

type Rows = sql.Rows

type StackTrace

type StackTrace []Frame

type Tx

type Tx struct {
	*sql.Tx
	*TxOptions
}

func (*Tx) NamedExec

func (t *Tx) NamedExec(query string, args map[string]any) (result Result, err error)

func (*Tx) NamedExecContext

func (t *Tx) NamedExecContext(ctx context.Context, query string, args map[string]any) (result Result, err error)

func (*Tx) NamedQuery

func (t *Tx) NamedQuery(query string, args map[string]any) (rows *Rows, err error)

func (*Tx) NamedQueryContext

func (t *Tx) NamedQueryContext(ctx context.Context, query string, args map[string]any) (rows *Rows, err error)

func (*Tx) NamedQueryRow

func (t *Tx) NamedQueryRow(query string, args map[string]any) (row *Row)

func (*Tx) NamedQueryRowContext

func (t *Tx) NamedQueryRowContext(ctx context.Context, query string, args map[string]any) (row *Row)

type TxController

type TxController interface {
	Transactional(
		ctx context.Context,
		f func(ctx context.Context) error,
		options *TxOptions,
	) (beginErr error, err error, commitErr error, rollbackErr error)
	BeginTx(ctx context.Context, options *TxOptions) (txCtx context.Context, err error)
	EndTx(ctx context.Context, txErr error) (rollbackErr error, commitErr error)
	CommitTx(ctx context.Context) (err error)
	RollbackTx(ctx context.Context) (err error)
}

type TxOptions

type TxOptions = sql.TxOptions

Jump to

Keyboard shortcuts

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