Skip to content
Prev 164 / 1559 Next

RODBC and BLOBS

Does RODBC support BLOBS? I ask because I would like to 
serialize(ascii=FALSE) an R variable and store it in a database table.
Is this doable?

My naive attempt went like this:

 > library(RODBC)
 > chan <- odbcConnect('test') # to mysql thru myodbc thru unixodbc
 > sqlQuery(chan,"create table vars( name varchar(255), val blob)")
[1] "No Data"
 > data(iris)
 > x<-serialize(iris,connection=NULL)
 > sqlQuery(chan,paste("insert into vars VALUES ('iris','",x,"')",sep=''))
character(0)
 > y<- sqlQuery(chan,"select * from vars")
 > z<-unserialize(y$val)
Error in unserialize(y$val) : 'connection' must be a connection
 > typeof(y$val)
[1] "integer"