Documentation ¶
Overview ¶
Package psqlutil provides PostgreSQL utility functions, offering the most common operations in the PSQL ecosystem.
Index ¶
- Variables
- func ComposeDSN(host, port, user, password, dbName, sslMode string) stringdeprecated
- func FindSQLDir() (string, error)
- func GormOpen(ctx context.Context, zapLogger *zap.Logger, postgresDSN string, ...) (*gorm.DB, error)
- func MustNewSQL(db *sql.DB, err error) *sql.DB
- func ReadSchema() (string, error)
- func SQLOpen(ctx context.Context, driver, postgresDSN string) (*sql.DB, error)
- type ConnectionConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrUnableToResolveCaller is returned when the caller CWD cannot be retrieved. ErrUnableToResolveCaller = errors.New("unable to resolve caller") // ErrProjectRootNotFound is returned when the // project root is not found. ErrProjectRootNotFound = errors.New("project root not found") )
Functions ¶
func ComposeDSN
deprecated
added in
v0.0.4
func FindSQLDir ¶ added in v0.0.6
FindSQLDir attempts to compose the path to the sql directory in the project. nolint: gocognit // allow high cog complexity.
func GormOpen ¶
func GormOpen( ctx context.Context, zapLogger *zap.Logger, postgresDSN string, ignoreRecordNotFoundErr bool, ) (*gorm.DB, error)
GormOpen opens a new db connection and returns a *gorm.DB.
func MustNewSQL ¶
MustNewSQL panics if err is not nil, otherwise it returns db.
func ReadSchema ¶ added in v0.0.2
ReadSchema reads schema dynamically based on the CWD of the caller.
Types ¶
type ConnectionConfig ¶ added in v0.0.9
type ConnectionConfig struct { Host string Port string User string Password string DBName string SSLMode string }
ConnectionConfig is a PostgreSQL connection configuration.
func (ConnectionConfig) DSN ¶ added in v0.0.9
func (c ConnectionConfig) DSN() string
DSN returns a PostgreSQL Data Source Name.
Click to show internal directories.
Click to hide internal directories.