So this works:
odbcConnect("TestDB", "admin", "password")
but I dont want the username and pwd in clear text. I figured simply write the credentials to a text file and import that file for use with:
odbcConnect(textFile)
Saving the credentials and calling readLines(textFile) produces a string with escape characters that throws the connections:
"odbcConnect(\"TestDB\", \"admin\", \"password\")"
I've tried legion of escape characters in the text file and also tried creating a string using paste but the result always comes back to a version of the line above. Anyone got a workaround or safer way to connect to SQL?
You can store the variables in a separate .r file.
username = yourusername
password = yourpassword
dsn = yourDB
In the script where you connect the ODBC you can then call the script that defines those variables.
source("variables.r")