Documentation
¶
Overview ¶
Package lyspgdb contains functions for creating and connecting to 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 CreateUserIfNotExists(ctx context.Context, db *pgxpool.Pool, userConf User, options []string) (err error)
- func DropDb(ctx context.Context, pgUserPgDb *pgxpool.Pool, dbName string) (err error)
- func ExecuteFile(ctx context.Context, db *pgxpool.Pool, sqlFileName string, sqlAssets embed.FS, ...) (err error)
- func GetConfig(dbConfig Database, userConfig User, appName string) (cfg *pgxpool.Config, err error)
- func GetPool(ctx context.Context, dbConfig Database, userConfig User, appName string) (db *pgxpool.Pool, err error)
- func GetPoolWithTypes(ctx context.Context, dbConfig Database, userConfig User, appName string, ...) (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 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 CreateUserIfNotExists ¶ added in v0.1.48
func DropDb ¶
DropDb deletes a database pgUserPgDb is a connection to the postgres database with the postgres user
func ExecuteFile ¶ added in v0.1.46
func ExecuteFile(ctx context.Context, db *pgxpool.Pool, sqlFileName string, sqlAssets embed.FS, replacementsMap map[string]string, infoLog *slog.Logger) (err error)
ExecuteFile extracts the supplied file from the supplied filesystem and executes it into supplied database
func GetConfig ¶
GetConn returns a connection pool to the postgres database matching the config params
func GetPool ¶
func GetPool(ctx context.Context, dbConfig Database, userConfig User, appName string) (db *pgxpool.Pool, err error)
GetPool returns a connection pool to the postgres database matching the config params
func GetPoolWithTypes ¶
func GetPoolWithTypes(ctx context.Context, dbConfig Database, userConfig User, appName string, dataTypeNames []string) (db *pgxpool.Pool, err error)
GetPoolWithTypes returns a connection pool and registers the supplied types to each connection