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

From: Rainer M Krug <rkrug_at_sun.ac.za>
Date: Tue 27 Jun 2006 - 23:25:47 EST

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

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

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:		+27 - (0)72 808 2975 (w)
Fax:		+27 - (0)21 808 3304
Cell:		+27 - (0)83 9479 042

email:	RKrug@sun.ac.za
      	Rainer@krugs.de

______________________________________________
R-help@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
Received on Tue Jun 27 23:32:32 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 28 Jun 2006 - 02:12:42 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.