pgsql

package module
v0.0.0-...-14f7b91 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2023 License: MIT Imports: 8 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

pgsql

AFAIRE


Copyright (c) 2022-2023 Archivage Numérique

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoRows = pgx.ErrNoRows

Functions

func CtxWithTimeout

func CtxWithTimeout(timeout time.Duration) (context.Context, context.CancelFunc)

Types

type Config

type Config struct {
	Name              string        `dm:"name"`
	Host              string        `dm:"host"`
	Port              int           `dm:"port"`
	Username          string        `dm:"username"`
	Password          string        `dm:"password"`
	MaxConns          int           `dm:"max_conns"`
	MinConns          int           `dm:"min_conns"`
	MaxConnLifetime   time.Duration `dm:"max_conn_lifetime"`
	MaxConnIdleTime   time.Duration `dm:"max_conn_idle_time"`
	HealthCheckPeriod time.Duration `dm:"health_check_period"`
	ConnectTimeout    time.Duration `dm:"connect_timeout"`
	Logger            Logger
}

type Database

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

func NewDatabase

func NewDatabase(c *Config) (*Database, error)

func (*Database) Close

func (db *Database) Close()

func (*Database) Execute

func (db *Database) Execute(ctx context.Context, sql string, args ...any) (int64, error)

func (*Database) Name

func (db *Database) Name() string

func (*Database) Pool

func (db *Database) Pool() *pgxpool.Pool

func (*Database) Query

func (db *Database) Query(ctx context.Context, sql string, args ...any) (Rows, error)

func (*Database) QueryRow

func (db *Database) QueryRow(ctx context.Context, sql string, args ...any) Row

func (*Database) Transaction

func (db *Database) Transaction(ctx context.Context, fn func(*Transaction) error) error

type Logger

type Logger interface {
	Trace(msg string, kv ...any)
	Debug(msg string, kv ...any)
	Info(msg string, kv ...any)
	Warning(err error, msg string, kv ...any)
	Error(err error, msg string, kv ...any)
}

type Row

type Row interface {
	Scan(dest ...any) error
}

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...any) error
	Close()
	Err() error
}

type Transaction

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

func (*Transaction) Execute

func (t *Transaction) Execute(sql string, args ...any) (int64, error)

func (*Transaction) Query

func (t *Transaction) Query(sql string, args ...any) (Rows, error)

func (*Transaction) QueryRow

func (t *Transaction) QueryRow(sql string, args ...any) Row

Jump to

Keyboard shortcuts

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