Help us shape the future of Go! Take the 2026 Go Developer Survey

database

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaskSecret

func MaskSecret(dsn string) string

Types

type DB

type DB interface {
	QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)
	BeginTransaction(ctx context.Context) (Transaction, error)
	Close() error
}

func NewDatabase

func NewDatabase(dsn string) (DB, error)

type Database

type Database struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func (*Database) BeginTransaction

func (d *Database) BeginTransaction(ctx context.Context) (Transaction, error)

func (*Database) ExecContext

func (d *Database) ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)

func (*Database) QueryRowsContext

func (d *Database) QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)

type Transaction

type Transaction interface {
	QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)
	Rollback() error
	Commit() error
}

type Tx

type Tx struct {
	*sqlx.Tx
}

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) ExecContext

func (t *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)

func (*Tx) QueryRowsContext

func (t *Tx) QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)

func (*Tx) Rollback

func (t *Tx) Rollback() error

Jump to

Keyboard shortcuts

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