Skip to content
Prev 12117 / 15274 Next

RMySQL - setDefaults requires clear text name/password?

I think there is some "system-level magic" that getSymbols.MySQL is
breaking. The MySQL driver will actually find the information in the 
.my.cnf file if it is called without user and password, but the code 
does not try that:


 >      if (is.null(user) || is.null(password) || is.null(dbname)) {
 >          stop(paste("At least one connection argument (", sQuote("user"),
 >              sQuote("password"), sQuote("dbname"), ") is not set"))
 >      }
 >      con <- dbConnect("MySQL", user = user, password = password,
 >          dbname = dbname, host = host, port = port)

I think it will be fixed by (untested)

    if ( is.null(dbname))
        stop('dbname must be specified')
    if (is.null(user) & is.null(password) )
      con <- dbConnect("MySQL", dbname = dbname)
    else
      con <- dbConnect("MySQL", user = user, password = password,
          dbname = dbname, host = host, port = port)

This could probably do something better if the user manages to specify 
one of user or password, or host, or port.

Paul.
On 13-12-20 04:30 PM, Mark Knecht wrote: