stdsqlexec

package module
v0.0.0-...-591bdfc Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package stdsqlexec is the sqlkit.Executor over database/sql.

It runs statements through a *sql.DB, or through the *sql.Tx a context carries, and gives transactions the contract every executor shares: whoever begins commits, a nested scope joins and flattens rather than taking a savepoint, and an error, a panic or a cancelled context rolls back.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithTx

func ContextWithTx(ctx context.Context, tx *sql.Tx) context.Context

ContextWithTx returns a context carrying an open transaction, so that a caller that began one itself can have the executor join it. The executor uses this transaction and neither commits nor rolls it back.

The key is this package's own, so a transaction a task store carries is not visible here. A host that wants one transaction across both reads it from the store's context and passes it here.

func TxFromContext

func TxFromContext(ctx context.Context) (*sql.Tx, bool)

TxFromContext returns the transaction active on a context, if any.

Types

type Executor

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

Executor runs statements through a *sql.DB, or through the *sql.Tx a context carries.

func New

func New(db *sql.DB, dialect sqlkit.Dialect) (*Executor, error)

New returns an executor over a database handle and the dialect of the database behind it. A nil handle or dialect is a configuration error.

func (*Executor) DB

func (e *Executor) DB() *sql.DB

DB returns the underlying handle.

func (*Executor) Dialect

func (e *Executor) Dialect() sqlkit.Dialect

Dialect implements sqlkit.Executor.

func (*Executor) Do

func (e *Executor) Do(ctx context.Context, fn func(ctx context.Context) error) error

Do implements sqlkit.Executor.

func (*Executor) Exec

func (e *Executor) Exec(ctx context.Context, statement sqlkit.Statement) (int64, error)

Exec implements sqlkit.Executor.

func (*Executor) ExecStatement

func (e *Executor) ExecStatement(ctx context.Context, query string, args ...any) error

ExecStatement implements sqlkit.Execer, so that the schema runner can drive this executor.

func (*Executor) InTransaction

func (e *Executor) InTransaction(ctx context.Context) bool

InTransaction implements sqlkit.Executor.

func (*Executor) Query

func (e *Executor) Query(ctx context.Context, statement sqlkit.Statement, scan func(rows sqlkit.Rows) error) error

Query implements sqlkit.Executor.

func (*Executor) QueryStatement

func (e *Executor) QueryStatement(ctx context.Context, query string, args ...any) (sqlkit.Rows, error)

QueryStatement implements sqlkit.Querier, so that schema verification can drive this executor.

Jump to

Keyboard shortcuts

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