db

package
v0.0.0-...-678e9c6 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionInfo

type ConnectionInfo struct {
	Host     string `env:"PGHOST" envDefault:"localhost"`
	Port     uint16 `env:"PGPORT" envDefault:"5432"`
	User     string `env:"PGUSER" envDefault:"postgres"`
	Database string `env:"PGDATABASE" envDefault:"postgres"`
	Password string `env:"PGPASS"`
}

func LoadConnectionInfoEnv

func LoadConnectionInfoEnv() *ConnectionInfo

func LoadConnectionInfoWithConfigFile

func LoadConnectionInfoWithConfigFile(configFile *config.ConfigEnvironment) *ConnectionInfo

func NewConnectionInfo

func NewConnectionInfo(
	host string,
	port uint16,
	database string,
	user string,
	pass string,
) *ConnectionInfo

func (*ConnectionInfo) String

func (c *ConnectionInfo) String() string

type PgxIface

type PgxIface interface {
	Begin(context.Context) (pgx.Tx, error)
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	Ping(context.Context) error
	Prepare(context.Context, string, string) (*pgconn.StatementDescription, error)
	Close(context.Context) error
}

func Connect

func Connect(connectionInfo *ConnectionInfo) PgxIface

creates a pgx connection to postgres database

Jump to

Keyboard shortcuts

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