[R] Rmysql - dbWritetable

Spencer Graves spencer.graves at structuremonitoring.com
Wed Oct 13 03:32:59 CEST 2010


        Please excuse:  "dbWriteTable" functions are mentioned in the 
documentation for packages RMySQL, RSQLite, ROracle, DBI, RJDBC, RpgSQL, 
RH2, sqldf, and RSQLite.extfuns, at least according to the following:


install.packages('sos') # if it's not already installed
library(sos)
(dbw <- ???dbWriteTable)


       This found 38 help pages in 10 packages matching "dbWriteTable".  
If you had provided "sessionInfo()", we'd at least know which one of 
these you were trying to use.


       Have you tried something like the following:


x2010 <- read.table('2010101000.txt')
dbWriteTable(con, "b20101010", x2010, overwrite = T)


       If this does not work, please note that there is a mailing list 
specifically for questions regarding database issues with R (R-SIG-DB:  
"https://stat.ethz.ch/mailman/listinfo/r-sig-db").


       Hope this helps,
       Spencer Graves


On 10/12/2010 5:57 PM, stephen sefick wrote:
> I don't have much experience with SQL, but I suspect that it is
> something like CHARACTER or NUMERIC... maybe.
>
> On Tue, Oct 12, 2010 at 7:47 PM, Nilza BARROS<nilzabarros at gmail.com>  wrote:
>> Dear Rusers,
>>
>> I am trying to feed my database with data from a file.
>>
>> But since my file (2010101000.txt) there`s no headers I am facing problem
>> because the
>> result data.frame is not separated my columns.
>>
>> How could I set variables names for each columns in *dbWriteTable*? I have
>> tried the command below but I don`t know how to fill the *field.type*option.
>>
>>
>> dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
>> "\t",row.names=c("V01", "V02", "V03", "V04", "V05", "V06"," V07","V08",
>> "V09", "V10", "V11", "V12", "V13", "V14"),field.type=????)
>>
>> ===Below what I have been used. I need to know how to set the column names
>> to xx (my dataframe).
>>
>>> drv=dbDriver("MySQL")
>>> con<- dbConnect(drv,dbname='buoy',user="xx",password="xxx")
>>> dbWriteTable(con, "b20101010", "./2010101000.txt", overwrite = T, sep =
>> "\t", head = F)
>> [1] TRUE
>>> *xx*<- dbGetQuery(con, "SELECT * FROM b20101010  ")
>>> xx
>> *  V1
>> *1 00859 2010 10 10 00 50  -41.51   6.83  -9999   1016  -9999 -9999.0
>> -9999.0 -9999.0
>> 2 00859 2010 10 09 22 50  -41.51   6.81  -9999   1015  -9999 -9999.0 -9999.0
>> -9999.0
>> 3 00707 2010 10 09 23 00  -34.04 -37.63  -9999   1025  -9999 -9999.0 -9999.0
>> -9999.0
>> 4 00005 2010 10 09 23 00  -34.69 -18.89  -9999   1017    207     7.2   297.1
>> -9999.0
>> 5 00859 2010 10 09 23 50  -41.51   6.81  -9999   1015  -9999 -9999.0 -9999.0
>> -9999.0
>> 6 00005 2010 10 09 23 00  -34.69 -18.89  -9999   1017    207     7.2   297.1
>> -9999.0
>> 7 00617 2010 10 09 23 20  -18.43 -23.09  -9999   1023  -9999 -9999.0 -9999.0
>> -9999.0
>> 8 00707 2010 10 10 00 00  -34.03 -37.62  -9999   1025  -9999 -9999.0 -9999.0
>> -9999.0
>> 9 00707 2010 10 10 01 00  -34.03 -37.62  -9999   1025  -9999 -9999.0 -9999.0
>> -9999.0
>> *>  length(xx)
>> [1] 1
>> *
>> --
>> Abraço,
>> Nilza Barros
>>
>>         [[alternative HTML version deleted]]
>>
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list