[R] RMySQL...Can't initialize driver???

David James dj at research.bell-labs.com
Tue Jun 27 22:36:24 CEST 2006


This looks very suspicious.  The function mysqlInitDriver
is pretty straight forward (see below), but the error you're reporting
apparently has something to do with S4 dispatching:

  > mysqlInitDriver
  function (max.con = 16, fetch.default.rec = 500, force.reload = FALSE)
  {
      if (fetch.default.rec <= 0)
          stop("default num of records per fetch must be positive")
      config.params <- as.integer(c(max.con, fetch.default.rec))
      force <- as.logical(force.reload)
      drvId <- .Call("RS_MySQL_init", config.params, force, PACKAGE = .MySQLPkgName)
      new("MySQLDriver", Id = drvId)
  }

Could you send me the output of 

   R --vanilla
   library(RMySQL)
   search()
   ## ask R to put you in a browser in case of errors
   options(error = recover)   

   con <- MySQL(max.con = 10, fetch.default.rec=500, force.reload = F)

when you encounter the error, you'll be prompted with

     "Enter a frame number, or 0 to exit"
  
type 2 (or the number for the call to mysqlInitDriver(max.con = ...))
and then find out what class of object is "drvId" (it should be "integer").
    
    Browser[1]>  class(drvId)
    

Regards,

--
David

   
  

Stephane Cruveiller wrote:
> Rainer M Krug wrote:
> >Stephane Cruveiller wrote:
> >  
> >>Duncan Murdoch wrote:
> >>    
> >>>On 6/27/2006 8:51 AM, Stephane Cruveiller wrote:
> >>>      
> >>>>Dear R users,
> >>>>
> >>>>I would like to query a MySQL database through R. I have installed
> >>>>the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL
> >>>>server (v5.0.22) is running on my local machine but I can't
> >>>>initialize MYSQL
> >>>>driver:
> >>>>------------------------------------------------------------------------------------
> >>>>
> >>>> > library("RMySQL")
> >>>>Loading required package: DBI
> >>>> > MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F)
> >>>>Error in new("MySQLDriver", Id = drvId) : unused argument(s) (Id ...)
> >>>>-------------------------------------------------------------------------------------
> >>>>
> >>>>
> >>>>Could somebody tell me what I have missed?
> >>>>        
> >
> >I am running R 2.3.0 under Linux and connect to a MySQl 4.1 server.
> >
> >You have to create a file in your home directory which has the
> >connection infos. It should look like that:
> >
> >				
> >[renpatch]
> >user = UserName
> >password = PassWord
> >database = ...
> >host = ...
> >
> >[renpatch_renosterbos]
> >user = UserName
> >password = PassWord
> >database = ...
> >host = ..
> >
> >and be called .my.conf
> >
> >  
> I followed your instruction. Here is my .my.cnf:
> ---------------------------------------------------------------------------
> [client]
> user=steff
> password=XXXXXX
> database=justforfun
> ---------------------------------------------------------------------------
> with it, I can connect to my MYSQL server without problem
> and then I try to connect through R:
> 
> ---------------------------------------------------------------------------
> > library(RMySQL)
> Loading required package: DBI
> > m <- dbDriver("MySQL")
> Error in new("MySQLDriver", Id = drvId) : unused argument(s) (Id ...)
> ---------------------------------------------------------------------------
> 
> It still produces the error. I really  do not  know what is going on here...
> 
> 
> >Then you do:
> >
> >
> >library("RMySQL")
> >m <- dbDriver("MySQL")
> >con <- dbConnect(m, group = "renpatch")
> >q <- TheSQLQuery
> >rs <- dbSendQuery(con, q)
> >TheResults <- fetch(rs, n = -1)
> >dbDisconnect(con)
> >rm(con)
> >
> >
> >and it should work - at least that is what it is doing for me.
> >
> >Rainer
> >
> >  
> 
> Stephane.
> 

> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



More information about the R-help mailing list