#' import postgres data
#'
#' @description This function imports data
#' @param file is the sql script. startDate the Date your query starts from (default is 2018-01-01). endDate latest considered date in your query (default is today()).
#' @return datatframe, tibble
#' @keywords import
#' @import DBI, readr
#' @export
#' @examples loadByQuery("yourSQLScript.sql", startDate = startDate, endDate = endDate)
loadByQuery <- 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 <- dbGetQuery(connPostgres, select)
return(result)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.