#' import postgres data using dbx
#'
#' @description This function imports data
#' @param file is the sql script.
#' @param startDate the Date your query starts from (default is 2018-01-01).
#' @param endDate latest considered date in your query (default is today()).
#' @return datatframe, tibble
#' @keywords import
#' @import DBI, readr, dbx
#' @export
#' @examples loadByQuery("yourSQLScript.sql", startDate = startDate, endDate = endDate)
conn <- function (file, startDate = "2018-01-01", endDate = paste0((lubridate::today())))
{
select <- DBI::sqlInterpolate(DBI::ANSI(), readr::read_file(paste0(getwd(),
file)),
startDate = startDate,
endDate = endDate)
result <- dbx::dbxSelect(condbx, select)
return(result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.