database

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: MIT Imports: 4 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 (DB) BeginTx

func (db DB) BeginTx(ctx context.Context, write bool) (QuerierTx, error)

func (DB) Conn

func (db DB) Conn() *sql.DB

type DebugDB

type DebugDB struct {
	*sql.DB
}

func NewDebugDB

func NewDebugDB(db *sql.DB) DebugDB

func (DebugDB) BeginTx

func (db DebugDB) BeginTx(ctx context.Context, write bool) (QuerierTx, error)

func (DebugDB) Conn

func (db DebugDB) Conn() *sql.DB

func (DebugDB) ExecContext

func (db DebugDB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (DebugDB) QueryContext

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

type DebugTx

type DebugTx struct {
	*sql.Tx
}

func (DebugTx) Commit

func (tx DebugTx) Commit() error

func (DebugTx) ExecContext

func (tx DebugTx) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)

func (DebugTx) QueryContext

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

func (DebugTx) Rollback

func (tx DebugTx) Rollback() error

type Querier

type Querier interface {
	Conn() *sql.DB
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	BeginTx(ctx context.Context, write bool) (QuerierTx, error)
}

func New

func New(dbPath string, debug bool) (Querier, error)

type QuerierTx

type QuerierTx interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	Commit() error
	Rollback() error
}

Jump to

Keyboard shortcuts

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