sqlitex

package
v0.0.0-...-0941746 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: AGPL-3.0 Imports: 5 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 {
	// contains filtered or unexported fields
}

func Open

func Open(file string, options *DBOptions) (db *DB, err error)

func (*DB) Close

func (db *DB) Close() (err error)

func (*DB) Exec

func (db *DB) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)

Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*DB) Get

func (db *DB) Get(ctx context.Context, dest any, query string, args ...any) error

Get a single record. Any placeholder parameters are replaced with supplied args. An `ErrNoRows` error is returned if the result set is empty.

func (*DB) Query

func (db *DB) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)

Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

func (*DB) Select

func (db *DB) Select(ctx context.Context, dest any, query string, args ...any) error

Select an array of records. Any placeholder parameters are replaced with supplied args.

func (*DB) Transaction

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

type DBOptions

type DBOptions struct {
	BusyTimeout int64
}

type Queryer

type Queryer interface {
	Get(ctx context.Context, dest any, query string, args ...any) error
	Select(ctx context.Context, dest any, query string, args ...any) error
	Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	Exec(ctx context.Context, query string, args ...any) (sql.Result, error)
}

type Tx

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

Transaction is wrapper of `sqlx.Tx` which implements `Tx`

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit commits the transaction.

func (*Tx) Exec

func (tx *Tx) Exec(ctx context.Context, query string, args ...any) (sql.Result, error)

Exec executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*Tx) Get

func (tx *Tx) Get(ctx context.Context, dest any, query string, args ...any) error

Get a single record. Any placeholder parameters are replaced with supplied args. An `ErrNoRows` error is returned if the result set is empty.

func (*Tx) Query

func (tx *Tx) Query(ctx context.Context, query string, args ...any) (*sql.Rows, error)

Query executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback aborts the transaction.

func (*Tx) Select

func (tx *Tx) Select(ctx context.Context, dest any, query string, args ...any) error

Select an array of records. Any placeholder parameters are replaced with supplied args.

Jump to

Keyboard shortcuts

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