Serialized object to mysql database in R -
if have serialized data like:
> <- 1:5 > [1] 1 2 3 4 5 > b <- serialize(a,null) > b [1] 58 0a 00 00 00 02 00 02 0f 02 00 02 03 00 00 00 00 0d 00 00 00 05 00 00 00 01 00 00 00 02 00 00 00 03 00 00 00 04 00 00 00 05 > b[1] [1] 58 > b[8] [1] 02
how can put serialized data mysql table? have other info there also. read can done blob, don't know how works. using rmysql. have tried:
dbgetquery(con, "insert table(",b," info, moreinfo, otherstuff, more, date )")
but won't work.
if use
query <- paste ("insert table(",b," info, moreinfo, otherstuff, more, date )") dbgetquery(con,query)
it still won't work.
try this:
library(rodbc) dt=data.table(a=sample(10),b=sample(10)*10) sqlsave(con, dt, tablename='sampletablename') # overwrites existing sampletablename table sqlsave(con, dt, tablename='sampletablename', append=true) # append instead of overwrite
Comments
Post a Comment