Documentation ¶
Overview ¶
Package psql interfaces with Postgresql.
Index ¶
Constants ¶
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 ¶
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 ¶
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.
Types ¶
This section is empty.