Someone solved the problem of saving R-objects to a database?

These are the two varaints I've tried so far without success:

1)
ser = rawToChar(serialize(obj, NULL, ascii=TRUE))
dbSendQuery(link, paste("insert into table values(1, '",ser,"')",sep=''))

The field to save the object in the MySQL Database is of type text.

unser = dbGetQuery(link,"select * from table where id=1")
Warning message:
In mysqlFetch(res, n, ...) :
  RS-DBI driver warning: (internal error: row 0 field 1 truncated)


2)
ser = serialize(obj, NULL)
dbSendQuery(link, paste("insert into table values(1, '",ser,"')",sep=''))

The field to save the object in the MySQL Database is of type blob.

result = dbGetQuery(link,"select * from table where id=1")

unser = unserialize(result[1,"object_column"], NULL)
Error in unserialize(result[1, "object_column"], NULL) : unknown input format
In addition: Warning message:
In unserialize(result[1, "object_column"], NULL) :
unserialize()from a character string is deprecated and will be withdrawn in R 2.8.0


Any suggestion is welcome.

Best,
Christian

______________________________________________
R-help@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.

Reply via email to