R/sql_quote.R

Defines functions sql_quote.PqConnection sql_quote.MySQLConnection sql_quote.SQLiteConnection sql_quote

Documented in sql_quote

#' S3 method to escape SQL variables accordingly
#'
#' @param con Database connection or R table object.
#' @param x A string to quote.
#' @param ... Currently not used.
#' 
#' @author Andreas Scharmueller, \email{andschar@@protonmail.com}
#' 
sql_quote = function(...) {
  UseMethod('sql_quote')
}

sql_quote.SQLiteConnection = function(con, x) {
  paste0('"', x, '"')
}

sql_quote.MySQLConnection = function(con, x) {
  paste0('`', x, '`')
}

sql_quote.PqConnection = function(con, x) {
  paste0('"', x, '"')
}

sql_quote.PostgreSQLConnection = sql_quote.PqConnection
andschar/dbreport documentation built on Dec. 8, 2022, 3:29 p.m.