title: How to secure database username and password with R DBI?
body: <p>When connecting to a database using the <code>dbConnect</code> function in the <code>DBI</code> package, what are the best practices for securing logon information such as database name, username and password?</p>
  
  <p>Entering logon information as a character text such as</p>
  
  <pre><code>library(RPostgreSQL)
  drv = dbDriver("PostgreSQL")
  con = dbConnect(drv, dbname = "&lt;DBNAME&gt;", host = "&lt;HOST&gt;",
                  port = 5432, user = "&lt;USER&gt;", password = "&lt;PASSWORD&gt;")
  </code></pre>
  
  <p>leaves the credentials open and in plain text.  How can the logon information be protected when using it in an R script?</p>