R/sql.template-package.R

#' @name sql.template
#'
#' @title sql.template - lightweight SQL templating engine
#'
#' @description
#' \strong{sql.template} is a simple, mustache-based SQL templating library. It
#' allows writing syntactically valid SQL that can execute as-is and
#' simultaneously support injection of values programattically before sending
#' the query for execution. It has three main functions
#'
#' \itemize{
#'   \item substitution using \code{whisker} templates
#'   \item tags that allow for unmasking/uncommenting of SQL templating code
#'   \item read SQL from any connection-type object such as a file.
#' }
#'
#' The package was designed so that the developers could share SQL code between
#' developers from a shared or forked repository. It is very amenable to use
#' with any of the R piping libraries.
#'
#' @seealso
#'   \link{sql} \cr
#'   sqlutils: \url{https://github.com/jbryer/sqlutils} for an alternative
#'   approach\cr
#'
#' @examples
#'
#' sql = "
#' SELECT
#'   *
#' FROM
#'   {{table}}
#' WHERE
#'   1 == 1
#' --fn: and FIRST_NAME = '{{first_name}}' /*ln: and LAST_NAME = '{{last_name}}'*/
#' "
#'
#' replacement <- list( table = "pres", first_name = "Barack", last_name = "Obama" )
#'
#' # COMPARE THE FOLLOWING:
#'
#' sql_render( sql, replacement, render=FALSE, strip.comments = FALSE )
#' sql_render( sql, replacement )      # render
#' sql_render( sql, replacement, "fn" ) # render 'fn' tags
#' sql_render( sql, replacement, c("fn","ln") ) # render 'fn' tags
#'
#' @references
#'   \url{http://en.wikipedia.org/wiki/Mustache_(template_system)} \cr
#'   \url{http://mustache.github} \cr
#'   \url{https://github.com/edwindj/whisker}
#'
#' @docType package

NULL
decisionpatterns/sql.template documentation built on July 6, 2020, 8:41 a.m.