database

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 3 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 {
	Conn *sql.DB
	// contains filtered or unexported fields
}

func Open

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

func (*DB) Close

func (db *DB) Close() error

func (*DB) Exec added in v0.4.0

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

Exec delegates to the active transaction if present, otherwise to Conn.

func (*DB) Migrate

func (db *DB) Migrate() error

func (*DB) Query added in v0.4.0

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

Query delegates to the active transaction if present, otherwise to Conn.

func (*DB) QueryRow added in v0.4.0

func (db *DB) QueryRow(query string, args ...any) *sql.Row

QueryRow delegates to the active transaction if present, otherwise to Conn.

func (*DB) RunInTx added in v0.4.0

func (db *DB) RunInTx(fn func() error) error

RunInTx executes fn within a database transaction. If a transaction is already active (nested call), fn is called directly without creating a new transaction. On error or panic, the transaction is rolled back.

type DBTX added in v0.4.0

type DBTX interface {
	Exec(query string, args ...any) (sql.Result, error)
	Query(query string, args ...any) (*sql.Rows, error)
	QueryRow(query string, args ...any) *sql.Row
}

DBTX is the common interface between *sql.DB and *sql.Tx.

Jump to

Keyboard shortcuts

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