pgdb

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2021 License: MPL-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DbPool *pgxpool.Pool

DbPool is PGX pool connection to be used inside this application

Qb is the query builder exported, initiated from Connect function

View Source
var StdDb *sql.DB

StdDb is exported for any database connected tasks / usage, it should be initiated using ConnectStdLib function

Functions

func ConnectPgxPool

func ConnectPgxPool(c Config) error

ConnectPgxPool initializes the PGX pool connection

func ConnectStdLib

func ConnectStdLib(c Config) error

ConnectStdLib initiate the connection to database with pgx stdlib

func DoExec

func DoExec(ctx context.Context, builtQuery squirrelBuiltQuery) (pgconn.CommandTag, error)

DoExec takes a finished Squirrel's query builder and perform it using PGX

func DoQuery

func DoQuery(ctx context.Context, builtQuery squirrelBuiltQuery) (pgx.Rows, error)

DoQuery takes a finished Squirrel's query builder and perform query using PGX

func DoQueryRow

func DoQueryRow(ctx context.Context, builtQuery squirrelBuiltQuery) (pgx.Row, error)

DoQueryRow takes a finished Squirrel's query builder and perform query using PGX

func MigrateEntryPoint

func MigrateEntryPoint(config Config, optionally1EmbeddedDirs ...embed.FS)

MigrateEntryPoint is the entrypoint for DB migration commands. If config.MigrationFromEmbedded is true, the (optional) embedded migration directory must then be set (only 1 is accepted)

the simplest way to include the embed: import "embed" //go:embed migrations var embeddedMigrations embed.FS

Types

type Config

type Config struct {
	Host                             string `yaml:"Host"`
	Port                             int    `yaml:"Port"`
	Database                         string `yaml:"Database"`
	Username                         string `yaml:"Username"`
	Password                         string `yaml:"Password"`
	SSL                              string `yaml:"SSL"`
	MigrationStatementTimeoutSeconds int    `yaml:"migrationStatementTimeoutSeconds"`
	MigrationFromEmbedded            bool   `yaml:"MigrationFromEmbedded"`
	MigrationDirectory               string `yaml:"MigrationDirectory"`
}

func (Config) GetDsn

func (c Config) GetDsn() string

Jump to

Keyboard shortcuts

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