Skip to content

These generics translate individual values into SQL. The core generics are DBI::dbQuoteIdentifier() andDBI::dbQuoteString for quoting identifiers and strings, but dbplyr needs additional tools for inserting logical, date, date-time, and raw values into queries.


sql_escape_logical(con, x)

sql_escape_date(con, x)

sql_escape_datetime(con, x)

sql_escape_raw(con, x)

See also


con <- simulate_dbi()
sql_escape_logical(con, c(TRUE, FALSE, NA))
#> [1] "TRUE"  "FALSE" "NULL" 
sql_escape_date(con, Sys.Date())
#> [1] "'2023-11-02'"
sql_escape_date(con, Sys.time())
#> [1] "'2023-11-02 19:02:25.911858'"
sql_escape_raw(con, charToRaw("hi"))
#> [1] "X'6869'"