Opens a connection to a PostgreSQL database containing fwapg (and
optionally bcfishpass / bcfishobs). Connection parameters follow the
standard libpq conventions, so frs_db_conn() connects to whatever the
caller's environment points at, e.g. the local fwapg Docker database
in docker/, or a remote host.
Value
A DBI::DBIConnection object.
Details
Parameters resolve in this order:
Explicit arguments, field by field.
Standard libpq environment variables (
PGHOST,PGPORT,PGDATABASE,PGUSER,PGPASSWORD,PGSERVICE, ...). If any ofPGHOST,PGHOSTADDR,PGPORT,PGDATABASE,PGUSERorPGSERVICEis set, libpq resolves the unset fields itself and the legacy variables below are ignored.Legacy
PG_*_SHAREvariables (PG_DB_SHARE,PG_HOST_SHARE,PG_PORT_SHARE,PG_USER_SHARE,PG_PASS_SHARE), used only when none of the standard variables are set. Deprecated: a message is shown once per session.libpq defaults (local socket or
localhost, OS user name,~/.pgpass,~/.pg_service.conf).
The two variable groups are never mixed, so a legacy database name can not be paired with a standard host.
See also
Other database:
frs_db_query(),
frs_migration_trial()
Examples
if (FALSE) { # \dontrun{
# Standard libpq env vars, e.g. in ~/.Renviron:
# PGHOST=localhost PGPORT=5432 PGDATABASE=fwapg PGUSER=postgres
conn <- frs_db_conn()
DBI::dbDisconnect(conn)
# Explicit arguments override the environment per field
conn <- frs_db_conn(port = 63333, dbname = "bcfishpass")
DBI::dbDisconnect(conn)
} # }
