Quote postgres strings, identifiers, and literals
Source:R/dbQuoteIdentifier_PqConnection_Id.R, R/dbQuoteIdentifier_PqConnection_SQL.R, R/dbQuoteIdentifier_PqConnection_character.R, and 5 more
quote.RdIf an object of class Id is used for dbQuoteIdentifier(), it needs
at most one table component and at most one schema component.
Usage
# S4 method for class 'PqConnection,Id'
dbQuoteIdentifier(conn, x, ...)
# S4 method for class 'PqConnection,SQL'
dbQuoteIdentifier(conn, x, ...)
# S4 method for class 'PqConnection,character'
dbQuoteIdentifier(conn, x, ...)
# S4 method for class 'PqConnection'
dbQuoteLiteral(conn, x, ...)
# S4 method for class 'PqConnection,SQL'
dbQuoteString(conn, x, ...)
# S4 method for class 'PqConnection,character'
dbQuoteString(conn, x, ...)
# S4 method for class 'PqConnection,SQL'
dbUnquoteIdentifier(conn, x, ...)Arguments
- conn
A PqConnection created by
dbConnect()- x
A character vector to be quoted.
- ...
Other arguments needed for compatibility with generic (currently ignored).
Examples
library(DBI)
con <- dbConnect(RPostgres::Postgres())
x <- c("a", "b c", "d'e", "\\f")
dbQuoteString(con, x)
#> <SQL> 'a'
#> <SQL> 'b c'
#> <SQL> 'd''e'
#> <SQL> E'\\f'
dbQuoteIdentifier(con, x)
#> <SQL> "a"
#> <SQL> "b c"
#> <SQL> "d'e"
#> <SQL> "\f"
dbDisconnect(con)