Documentation ¶
Overview ¶
Package lyspgdb contains functions for creating and monitoring Postgres databases.
Index ¶
- func CreateDb(ctx context.Context, pgUserPgDb *pgxpool.Pool, dbName string) (err error)
- func CreateLocalDb(ctx context.Context, sqlAssets embed.FS, dbConf Database, ...) (err error)
- func DropDb(ctx context.Context, pgUserPgDb *pgxpool.Pool, dbName string) (err error)
- func GetConfig(dbConfig Database, userConfig User) (cfg *pgxpool.Config, err error)
- func GetPool(ctx context.Context, dbConfig Database, userConfig User) (db *pgxpool.Pool, err error)
- func GetPoolWithTypes(ctx context.Context, dbConfig Database, userConfig User, ...) (db *pgxpool.Pool, err error)
- func GrantAll(ctx context.Context, pgUserDb *pgxpool.Pool, userConf User, dbName string) (err error)
- func PopulateDb(ctx context.Context, db *pgxpool.Pool, sqlAssets embed.FS, ...) (err error)
- type Database
- type StatActivity
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDb ¶
CreateDb creates a database pgUserPgDb is a connection to the postgres database with the postgres user
func CreateLocalDb ¶
func CreateLocalDb(ctx context.Context, sqlAssets embed.FS, dbConf Database, dbSuperUser, dbOwnerConf User, dropExisting, addSecurityPermissions bool, replacementsMap map[string]string, infoLog *slog.Logger) (err error)
CreateLocalDb creates or recreates a test or dev db
func DropDb ¶
DropDb deletes a database pgUserPgDb is a connection to the postgres database with the postgres user
func GetConfig ¶
GetConn returns a connection pool to the postgres database matching the config params
func GetPool ¶
GetPool returns a connection pool to the postgres database matching the config params
func GetPoolWithTypes ¶
func GetPoolWithTypes(ctx context.Context, dbConfig Database, userConfig User, dataTypeNames []string) (db *pgxpool.Pool, err error)
GetPoolWithTypes returns a connection pool and registers the supplied types to each connection
Types ¶
type StatActivity ¶
type StatActivity struct { ApplicationName string `db:"application_name" json:"application_name"` ClientAddr string `db:"client_addr" json:"client_addr"` Pid int `db:"pid" json:"pid"` Query string `db:"query" json:"query"` QueryStart lystype.Datetime `db:"query_start" json:"query_start"` State string `db:"state" json:"state"` UseName string `db:"usename" json:"usename"` }
func GetStatActivity ¶
func GetStatActivity(ctx context.Context, db *pgxpool.Pool, dbName string) (items []StatActivity, stmt string, err error)
https://www.postgresql.org/docs/current/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW