I use R and RODBC to connect to an Oracle database and read data.
Typically my R models are developed initially in RStudio but I then transfer them to a Jupyter notebook where I document them further and share them with others. Sharing these notebooks is useful to others but one thing I don't want to share is my logon credentials.
cnxn <-odbcConnect("DBNAME", uid="uid", pwd="password")
To get around this, I store my credentials in a local text file and read them in when I run the notebook locally
cred <- read.delim('credentials.txt', header = FALSE)
In order to use credentials read in from a text file, you need to transform them to a character like this:
cnxn <-odbcConnect("DBNAME", uid=as.character(cred$V2), pwd=as.character(cred$V2))