dbEscapeStrings: Escape SQL-special characters in strings.

Description Usage Arguments Value Examples

Description

Escape SQL-special characters in strings.

Usage

1
2
3
4
5
6
7
dbEscapeStrings(con, strings, ...)

## S4 method for signature 'MySQLConnection,character'
dbEscapeStrings(con, strings)

## S4 method for signature 'MySQLResult,character'
dbEscapeStrings(con, strings, ...)

Arguments

con

a connection object (see dbConnect).

strings

a character vector.

...

any additional arguments to be passed to the dispatched method.

Value

A character vector with SQL special characters properly escaped.

Examples

1
2
3
4
5
6
7
8
if (mysqlHasDefault()) {
con <- dbConnect(RMySQL::MySQL(), dbname = "test")

tmp <- sprintf("SELECT * FROM emp WHERE lname = %s", "O'Reilly")
dbEscapeStrings(con, tmp)

dbDisconnect(con)
}

Example output

Loading required package: DBI
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.

RMySQL documentation built on June 22, 2021, 5:08 p.m.