sql

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package sql adapts application transactions to database/sql. Import as sqltx.

Index

Constants

This section is empty.

Variables

View Source
var ErrDifferentDatabase = errors.New("pfw: operation uses a different transaction database")

Functions

func New

func New(db *stdsql.DB, options Options) (*transaction.Manager, error)

New creates a manager to share across all use cases for this database.

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...any) (stdsql.Result, error)
	QueryContext(context.Context, string, ...any) (*stdsql.Rows, error)
	QueryRowContext(context.Context, string, ...any) *stdsql.Row
}

DBTX is the query surface shared by *sql.DB and *sql.Tx.

func Executor

func Executor(ctx context.Context, db *stdsql.DB) (DBTX, error)

Executor returns the active transaction for db, or db outside a scope. It never silently switches databases or falls back from an expired scope. Pass ctx to the returned executor's context-aware query methods as well.

type Options

type Options struct {
	Isolation       stdsql.IsolationLevel
	ReadOnly        bool
	RollbackTimeout time.Duration
}

Jump to

Keyboard shortcuts

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