Help us shape the future of Go! Take the 2026 Go Developer Survey

stdsql

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exec

func Exec(ctx context.Context, db *sqlx.DB, sql string) error

func Ping added in v0.21.0

func Ping(ctx context.Context, db *sqlx.DB) error

Ping checks that db answers. Without a query context it is the driver's own ping. With one it runs SELECT 1 carrying the query-context comment instead, because some drivers ping with SQL of their own (gosnowflake and athenadriver send SELECT 1, go-mssqldb select 1), which reaches the warehouse's query history without our marker.

func QueryAndProcessMany

func QueryAndProcessMany[T any](
	ctx context.Context,
	conn *sqlx.DB,
	sql string,
	handler func(ctx context.Context, rows []*T) error,
	opts ...exec.QueryManyOpt[T],
) error

func QueryMany

func QueryMany[T any](ctx context.Context, conn *sqlx.DB, sql string, opts ...exec.QueryManyOpt[T]) ([]*T, error)

func QueryMaps

func QueryMaps(ctx context.Context, conn *sqlx.DB, sql string) ([]exec.QueryMapResult, error)

Types

type Querier_Opts added in v0.2.5

type Querier_Opts[T any] func(querier *StdSqlQuerier[T])

func Querier_WithSshTunnelDialer added in v0.2.5

func Querier_WithSshTunnelDialer[T any](sshTunnelDialer *sshtunnel.SshTunnelDialer) Querier_Opts[T]

type StdSqlExecutor

type StdSqlExecutor interface {
	GetDb() *sqlx.DB
	QueryRows(ctx context.Context, q string, args ...interface{}) (*sqlx.Rows, error)
	Select(ctx context.Context, dest any, query string, args ...any) error
	Exec(ctx context.Context, query string, args ...any) error
}

type StdSqlQuerier

type StdSqlQuerier[T any] struct {
	// contains filtered or unexported fields
}

func NewQuerier

func NewQuerier[T any](conn *sqlx.DB, opts ...Querier_Opts[T]) *StdSqlQuerier[T]

func (StdSqlQuerier[T]) Close

func (s StdSqlQuerier[T]) Close() error

func (StdSqlQuerier[T]) Exec

func (s StdSqlQuerier[T]) Exec(ctx context.Context, sql string) error

func (StdSqlQuerier[T]) QueryAndProcessMany

func (s StdSqlQuerier[T]) QueryAndProcessMany(
	ctx context.Context,
	sql string,
	handler func(ctx context.Context, batch []*T) error,
	opts ...exec.QueryManyOpt[T],
) error

func (StdSqlQuerier[T]) QueryMany

func (s StdSqlQuerier[T]) QueryMany(ctx context.Context, sql string, opts ...exec.QueryManyOpt[T]) ([]*T, error)

func (StdSqlQuerier[T]) QueryMaps

func (s StdSqlQuerier[T]) QueryMaps(ctx context.Context, sql string) ([]exec.QueryMapResult, error)

Jump to

Keyboard shortcuts

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