database

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool manages database connections

func NewPool

func NewPool(cfg *config.DatabaseConfig) (*Pool, error)

NewPool creates a new database connection pool

func (*Pool) Begin

func (p *Pool) Begin(ctx context.Context) (*sql.Tx, error)

Begin starts a new transaction

func (*Pool) BeginTx

func (p *Pool) BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

BeginTx starts a new transaction with options

func (*Pool) Close

func (p *Pool) Close() error

Close closes all connections in the pool

func (*Pool) Exec

func (p *Pool) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec executes a query without returning rows

func (*Pool) GetDB

func (p *Pool) GetDB() *sql.DB

GetDB returns the underlying *sql.DB (use with caution)

func (*Pool) Health

func (p *Pool) Health(ctx context.Context) error

Health checks database health

func (*Pool) Ping

func (p *Pool) Ping(ctx context.Context) error

Ping checks if the database is reachable

func (*Pool) Query

func (p *Pool) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)

Query executes a SELECT query

func (*Pool) QueryRow

func (p *Pool) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow executes a query that returns at most one row

func (*Pool) Stats

func (p *Pool) Stats() sql.DBStats

Stats returns database statistics

Jump to

Keyboard shortcuts

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