database

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnString added in v0.1.2

func ConnString(cfg Config) string

ConnString translates config to a db connection string.

func Connect added in v0.1.2

func Connect(ctx context.Context, cfg Config) (*pgxpool.Pool, error)

Connect establishes a database connection based on the configuration.

func ConnstrWithDatabase added in v0.1.5

func ConnstrWithDatabase(connstr, database string) (string, error)

ConnstrWithDatabase changes the main database in the connection string.

func SanitizeDatabaseName added in v0.1.5

func SanitizeDatabaseName(schema string) string

SanitizeDatabaseName ensures that the database name is a valid postgres identifier.

func StatusCheck

func StatusCheck(ctx context.Context, db *pgxpool.Pool) error

StatusCheck returns nil if it can successfully talk to the database. It returns a non-nil error otherwise.

Types

type Config

type Config struct {
	User       string
	Password   string
	Host       string
	Name       string
	DisableTLS bool
}

Config is the required properties to use the database.

type DB added in v0.1.5

type DB struct {
	*pgxpool.Pool
}

func ConnectWithURI added in v0.1.5

func ConnectWithURI(ctx context.Context, uri string) (*DB, error)

Jump to

Keyboard shortcuts

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