View source: R/odbc-connection.R
quote_value | R Documentation |
When connecting to a database using odbc, all the arguments are concatenated
into a single connection string that looks like name1=value1;name2=value2
.
That means if your value contains =
or ;
then it needs to be quoted.
Other rules mean that you need to quote any values that starts or ends with
white space, or contains {
or }
.
This function quotes a string in a way that should work for most drivers, but unfortunately there doesn't seem to be an approach that works everywhere. If this function doesn't work for you, you'll need to carefully read the docs for your driver.
quote_value(x)
x |
A string to quote. |
A quoted string, wrapped in I()
.
quote_value("abc")
quote_value("ab'c")
# Real usage is more likely to look like:
## Not run:
library(DBI)
con <- dbConnect(
odbc::odbc(),
dsn = "reallycooldatabase"
password = odbc::quote_value(Sys.getenv("MY_PASSWORD"))
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.