psqlutil

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package psqlutil provides PostgreSQL utility functions, offering the most common operations in the PSQL ecosystem.

Index

Constants

This section is empty.

Variables

View Source
var ErrDirectoryNotFound = errors.New("wallee directory not found")

ErrDirectoryNotFound is returned when the project directory is not found.

View Source
var ErrUnableToResolveCaller = errors.New("unable to resolve caller")

ErrUnableToResolveCaller is returned when the caller CWD cannot be retrieved.

Functions

func ComposeDSN added in v0.0.4

func ComposeDSN(
	host,
	port,
	user,
	password,
	dbName,
	sslMode string,
) string

ComposeDSN returns a PostgreSQL Data Source Name.

func GormOpen

func GormOpen(
	ctx context.Context,
	zapLogger *zap.Logger,
	driver string,
	postgresDSN string,
) (*gorm.DB, error)

GormOpen opens a new db connection and returns a *gorm.DB.

func MustNewSQL

func MustNewSQL(db *sql.DB, err error) *sql.DB

MustNewSQL panics if err is not nil, otherwise it returns db.

func ReadSchema added in v0.0.2

func ReadSchema(projectDirectoryName string) (string, error)

ReadSchema reads schema dynamically based on the CWD of the caller.

func SQLOpen added in v0.0.5

func SQLOpen(
	ctx context.Context,
	driver,
	postgresDSN string,
) (*sql.DB, error)

SQLOpen opens a new db connection and returns a *sql.DB with a gorm driver.

Types

This section is empty.

Jump to

Keyboard shortcuts

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