db

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sql.DB
}

func Connect added in v0.1.3

func Connect(ctx context.Context, driverName, dsn string) (*DB, error)

Connect opens a database and verifies it is reachable with a ping. It never returns a half-open DB: on failure sqlDB is closed before returning the error.

func Open

func Open(driverName, dsn string) (*DB, error)

func (*DB) Transaction

func (d *DB) Transaction(ctx context.Context, fn func(tx *Tx) error) error

func (*DB) TransactionOpts added in v0.1.3

func (d *DB) TransactionOpts(ctx context.Context, opts *TransactionOpts, fn func(tx *Tx) error) error

TransactionOpts runs fn inside a transaction configured per opts.

type Executor

type Executor interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

type TransactionOpts added in v0.1.3

type TransactionOpts struct {
	Isolation sql.IsolationLevel
	ReadOnly  bool
}

TransactionOpts mirrors database/sql TxOptions. A nil *TransactionOpts means the database driver's default isolation level and read-write access.

type Tx

type Tx struct {
	*sql.Tx
}

Jump to

Keyboard shortcuts

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