sqlutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRows = errors.New("no rows found")

Functions

func BindAny

func BindAny(stmt *sqlite.Stmt, i int, arg any)

BindAny binds an argument to a statement.

func Borrow

func Borrow(ctx context.Context, pool *Pool, fn func(conn *Conn) error) error

Borrow retrieves a connection from the pool and calls fn with it. The connection is returned to the pool after fn is called.

func DoTx

func DoTx(ctx context.Context, pool *Pool, fn func(conn *Conn) error) error

func DoTx1

func DoTx1[T any](ctx context.Context, pool *Pool, fn func(conn *Conn) (T, error)) (T, error)

func DoTx2

func DoTx2[T1, T2 any](ctx context.Context, pool *Pool, fn func(conn *Conn) (T1, T2, error)) (T1, T2, error)

func DoTxRO

func DoTxRO(ctx context.Context, pool *Pool, fn func(conn *Conn) error) error

DoTxRO performs read-only transaction.

func Exec

func Exec(conn *Conn, query string, args ...any) error

Exec executes a query without returning rows

func Get

func Get[T any](conn *Conn, dest *T, query string, args ...any) error

Get retrieves a single value from a query result

func GetOne

func GetOne[T any](conn *Conn, dst *T, scan ScanFunc[T], query string, args ...any) (bool, error)

GetOne runs a query that expects a single row in the result. (false, nil) is returned to indicate that the query was successful but there was no value.

func IsErrNoRows

func IsErrNoRows(err error) bool

func ScanInt64

func ScanInt64(stmt *sqlite.Stmt, dst *int64) error

func ScanString

func ScanString(stmt *sqlite.Stmt, dst *string) error

func Select

func Select[T any](conn *Conn, scan func(stmt *sqlite.Stmt, dst *T) error, query string, args ...any) iter.Seq2[T, error]

Select returns an iterator over the results of the query. scan is called for each row.

func Vacuum

func Vacuum(conn *Conn) error

Vacuum performs a full database vacuum. It must not be called inside a transaction.

func WALCheckpoint

func WALCheckpoint(conn *Conn) error

WALCheckpoint checkpoints the Write Ahead Log. It must not be called inside a transaction.

Types

type Conn

type Conn = sqlite.Conn

type Iterator

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

func NewIterator

func NewIterator[T any](x iter.Seq2[T, error]) Iterator[T]

func (*Iterator[T]) Close

func (it *Iterator[T]) Close() error

func (*Iterator[T]) Drop

func (it *Iterator[T]) Drop()

func (*Iterator[T]) Next

func (it *Iterator[T]) Next(ctx context.Context, dst []T) (int, error)

type Pool

type Pool = sqlitex.Pool

Type aliases for convenience

func NewTestPool

func NewTestPool(t testing.TB) *Pool

func OpenPool

func OpenPool(p string) (*Pool, error)

type ScanFunc

type ScanFunc[T any] = func(stmt *sqlite.Stmt, dst *T) error

Jump to

Keyboard shortcuts

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