pgutil

package
v0.0.0-...-94dd193 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package pgutil provides utilities for Postgres

Index

Constants

View Source
const (
	SSLBlank      sslMode = ""
	SSLDisable            = "disable"
	SSLAllow              = "allow"
	SSLPrefer             = "prefer"
	SSLRequire            = "require"
	SSLVerifyCa           = "verify-ca"
	SSLVerifyFull         = "verify-full"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionOptions

type ConnectionOptions struct {
	Host     string
	Port     string
	User     string
	Password string
	DBName   string
	SSLMode  string
}

ConnectionOptions represents the configurable options of a connection to a Postgres database

func NewFromURL

func NewFromURL(rawurl string, opts ...Opts) (ConnectionOptions, error)

NewFromURL returns a ConnectionOptions from a given URL. This uses a format like `postgres://myuser:mypass@localhost/somedatabase`, which is commonly found on hosting platforms.

func (ConnectionOptions) String

func (c ConnectionOptions) String() string

String implements the Stringer interface so that a pgutil.ConnectionOptions can be converted into a value key/value connection string

type Opts

type Opts func(*ConnectionOptions)

func WithSSL

func WithSSL(requestedSslMode sslMode) Opts

WithSSL sets the sslmode parameter for postgresql. See the postgresql documentation at https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING

Jump to

Keyboard shortcuts

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