Skip to contents

Open and close PostgreSQL connections using credentials from environment variables. Each deployment environment sets ART_PGHOST, ART_PGPORT, ART_PGUSER, ART_PGPASS, and ART_PGDATA directly. See [README.md](https://github.com/artalytics/artcore#environment-variables) for the complete environment variable list.

Usage

dbc(cfg = NULL)

dbd(cn)

Arguments

cfg

Optional configuration name. Use `"artsite"` to connect to the marketing/leads database (reads `ART_PG*_SITE` env vars). Any other value or `NULL` uses the default env vars (`ART_PG*`).

cn

Database connection object to close.

Functions

  • dbc(): Open database connection

  • dbd(): Close database connection

Examples

if (FALSE) { # \dontrun{
# Primary database (default)
cn <- dbc()
DBI::dbGetQuery(cn, "SELECT 1")
dbd(cn)

# Marketing/leads database
cn <- dbc("artsite")
DBI::dbGetQuery(cn, "SELECT 1")
dbd(cn)
} # }