I am sourcing a file with some connectivity details, however, I would like to see the contents inside to ensure the correct credentials are used, below is my code:
I tried using dput(source(paste("mypath/credentials.r",sep="")))
but it doesn't really gives the content inside credentials.r
The output after dput is :structure(list(value = <S4 object of class structure("PostgreSQLConnection", package = "RPostgreSQL")>,
visible = FALSE), .Names = c("value", "visible"))
I am a little confused by as to what you are asking.
I think I and others would benefit if you could supply a copy of the minimal example of credentials.r credential contents. (obviously, pls don't actually include any private credentials)
And with that example, could you be explicit about what you expect to get?
You might consider following the advice under "Environment variables".
It suggests you setup a ~/.Renviron file in your base directory (be sure your version control ignores it). Put your host, dbname(s), port, user and password inside it.
E.g.
# .Renviron
CONNECTION_HOST=XXXX.com # not the website i was expecting
CONNECTION_PORT=5432
CONNECTION_DBNAME= serverxxx
CONNECTION_PASSWORD=XXXX
CONNECTION_USR=XXXX
Note that .Renviron is only processed on startup, so you’ll need to restart R to see changes.
And then you can access those values in R with Sys.getenv("CONNECTION_HOST"),