[R] write & read object from mysql
Gottfried Gruber
ggruber at terminal.at
Sun Mar 26 12:50:58 CEST 2006
hi,
i want to store an lm-object in mysql and use the following command:
dbSendQuery(con,paste("INSERT INTO tablename
(id,name,result,result_txt,rsquared) VALUES
(",x,",'",z2,"','",serialize(z1,NULL,ascii=F),"','",serialize(z1,NULL,ascii=T),"',",summary(z1)$r.squared,")",sep=""))
z1 is the lm-object
z2 is just as string
i try to read it back: v=dbReadTable(con,"tablename")
but i think the binary is stored wrong in the database and the text is too
long.
the binary stops on the first \n
the text is too long. when i try to read it back i get dbi internal error
field truncated.
in the end it is not possible to restore the object with unserialize.
please help me to write & read the object correctly.
thank & best regards,
gg
--
---------------------------------------------------
Gottfried Gruber
mailto:gottfried.gruber at terminal.at
www: http://gogo.sehrsupa.net
More information about the R-help
mailing list