[R] RMySQL problem

Ernesto Jardim ernesto at ipimar.pt
Mon May 24 16:56:20 CEST 2004


Hi,

I'm using R 1.9.0 with RMySQL 0.5-4 and MySQL 3.23.55 on a suse 8.2 box.

I have a simulation study and (as usual for newbies in simulation, I
guess) I have a lot of data that I want to store in MySQL. I want to
write an R script that reads data from RData files and writes it to a
MySQL database. 

I read some R documents (R Data Import/Export and DSC papers) but I'm
finding differences between the documents and the packages (RMySQL and
DBI). I don't find the methods to write data like "dbWriteTable"...

On the other hand I've tryied to build a sql statement to insert data
but I'm stucked because of ... who knows, my ignorance probably. I want
to take advantage of MySQl INSERT INTO statement that deals with several
rows at once to insert a complete data.frame into a table. I've tryied
to use "paste" to build the sql string but It works "by column" and I
need it "by row" ...

The sql systax should be something like:

INSERT INTO TABLEA(COL1, COL2, COL3) VALUES
	(VAL11, VAL12, VAL13),
	(VAL21, VAL22, VAL23),
	...
	(VALN1, VALN2, VALN3);

and I have a data.frame with 3 columns corresponding to that table
columns.

How can I do this ?

Thanks

EJ




More information about the R-help mailing list