Escape SQL-special characters in strings.
dbEscapeStrings(con, strings, ...)
# S4 method for class 'MySQLConnection,character'
dbEscapeStrings(con, strings)
# S4 method for class 'MySQLResult,character'
dbEscapeStrings(con, strings, ...)a connection object (see dbConnect).
a character vector.
any additional arguments to be passed to the dispatched method.
A character vector with SQL special characters properly escaped.
if (mysqlHasDefault()) {
con <- dbConnect(RMySQL::MySQL(), dbname = "test")
tmp <- sprintf("SELECT * FROM emp WHERE lname = %s", "O'Reilly")
dbEscapeStrings(con, tmp)
dbDisconnect(con)
}
#> Could not initialise default MySQL database. If MySQL is running
#> check that you have a ~/.my.cnf file that contains a [rs-dbi] section
#> describing how to connect to a test database.