I am using R to query data from a Postgres database. The query I created in pgAdmin3 has lots of escape characters in it, and I'd to pull in the entire SQL string without having to deal with escape characters again, something like Python's triple quotes """.
SELECT brand
,regexp_replace(upper(hybridtype), '\(.*\)|\/|-|TM|\s','','g') as hybrid
FROM seeds
How can I get that SQL text into R retaining all the characters?
in PGAdmin, copy the text into your clipboard. Then in R:
sql_qry <- clipPaste()
Where clipPaste is defined as follows:
clipPaste <- function(flat=TRUE) {
con <- pipe("pbpaste", open = "rb")
ret <- readLines(con, warn = FALSE)
if (flat)
ret <- paste0(ret, collapse = "\n")
close(con)
return(ret)
}
All characters will be appropriately escaped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With