sql

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRows = sql.ErrNoRows
)

Functions

func Up

func Up(ctx context.Context, db *DB, fsys fs.FS) error

Up from the current version.

Types

type DB

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

func Open

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

Open opens a database connection for the given sqlite file.

func (*DB) Begin

func (db *DB) Begin() (*Tx, error)

func (*DB) Close

func (db *DB) Close() error

Close closes the database and prevents new queries from starting. C

func (*DB) Exec

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

Exec executes a query without returning any rows.

func (*DB) Query

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

Query implements DB.

func (*DB) QueryRow

func (db *DB) QueryRow(ctx context.Context, query string, args ...any) Scanner

QueryRow executes a query that is expected to return at most one row.

type ReadWriter

type ReadWriter interface {
	Reader
	Writer
}

type Reader

type Reader interface {
	Query(ctx context.Context, query string, args ...any) (ScanIterator, error)
	QueryRow(ctx context.Context, query string, args ...any) Scanner
}

type ScanIterator

type ScanIterator interface {
	io.Closer
	Scanner
	Next() bool
}

type Scanner

type Scanner interface {
	Err() error
	Scan(dest ...any) error
}

type Tx

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

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) (int64, error)

Exec executes a query without returning any rows.

func (*Tx) Query

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

Query implements Tx.

func (*Tx) QueryRow

func (tx *Tx) QueryRow(ctx context.Context, query string, args ...any) Scanner

QueryRow executes a query that is expected to return at most one row.

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Rollback aborts the transaction.

type Writer

type Writer interface {
	Exec(ctx context.Context, query string, args ...any) (rowsAffected int64, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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