Re: [R] export from R to MySQL

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 13 Dec 2005 - 03:16:26 EST

On Mon, 12 Dec 2005, Sean Davis wrote:

>
>
>
> On 12/12/05 9:21 AM, "bogdan romocea" <br44114@gmail.com> wrote:
>
>>> Sean Davis wrote:
>>> but you will have to create the table by hand
>>
>> There's no need for manual steps. To take advantage of MySQL's
>> extremely fast 'load data infile' you could dump the data in CSV
>> format, write a script for mysql (the command line tool), for example
>>
>> q <- function(table,infile)
>> {
>> query <- paste("
>> create table ",table," (col1 float, col2 float);
>
> This is creating the table by hand, as opposed to using dbWriteTable. If
> your data.frame contains 67 columns, using dbWriteTable saves quite a bit of
> typing....

The RODBC equivalent creates the table for you, then fast imports the file. Might be worthwhile contribution to RMySQL for someone.

Just be careful with client-server systems to have the file in the right place (if indeed you are allowed to have files on the server).

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
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 Dec 13 03:40:54 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:35 EST