#' Postgres login
#'
#' Conect to postgres using DBI.
#'
#' @param user Username
#' @param pw Password
#' @param db Name of the database
#' @param host Host machine for the postgres server
#'
#' @return Postgres connection
#' @export
pg_connect <- function(user = NULL, pw = NULL, db = NULL, host = NULL) {
if (is.null(user)) {
stop("Please specify a user.", call. = FALSE)
}
login <- purrr::compact(
list(
host = host,
dbname = db,
user = user,
password = pw
))
pg_con <<- do.call(DBI::dbConnect, c(RPostgres::Postgres(), login))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.