psql

package
v0.0.0-...-46f3b6c Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package psql interfaces with Postgresql.

Index

Constants

View Source
const (
	// Select item by id. Takes id as argument.
	Item = `
SELECT *
FROM items
WHERE id = $1`

	// Select items for one day (range). Takes a date as argument.
	ForDay = `
SELECT *
FROM items
WHERE created BETWEEN $1 AND $1::date+1`
)

Variables

This section is empty.

Functions

func ConfigFromEnv

func ConfigFromEnv() *config

ConfigFromEnv returns a database pool configured from default psql env vars. See: https://www.postgresql.org/docs/current/libpq-envars.html

DEPRECATED: we just use the Postgresql env vars directly.

func GetConfig

func GetConfig() (*pgx.ConnConfig, error)

GetConfig parses the Postgresql connection settings from the environment.

DEPRECATED: we just use the Postgresql env vars directly.

func NewConnection

func NewConnection(ctx context.Context) (*pgx.Conn, error)

NewConnection makes a new connection to Postgresql using default PG* environment variables from the environment. See also NewConnectionFromApp if you want to override the application name in the connection settings.

func NewConnectionFromApp

func NewConnectionFromApp(ctx context.Context, app string) (*pgx.Conn, error)

NewConnectionFromApp makes a new Postgresql connection using default PG* environment variables. It will add (potentially overriding) the provided application name to the connection settings to facilitate debugging. Prefer this function for helper tools that make direct database connections.

func NewPool

func NewPool(ctx context.Context) (*pgxpool.Pool, error)

NewPool starts a new Postgresql pool using connection parameters defined in the environment. Prefer this pool function for the main database backend.

Types

This section is empty.

Jump to

Keyboard shortcuts

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