From: Aaron Smith Date: 2007-06-25T11:13:02+09:00 Subject: Re: insert marshall'd data into mysql Peter Cooper wrote: > On 6/25/07, Aaron Smith wrote: >> > non printable characters and all, into a database, you could Base64 >> @con.query("INSERT INTO user_data SET marshal='#{d}'"); >> >> That will produce an error because of some of the characters in the >> marshal string.. > > Use parameter binding. Not sure what library you're using, but with > Ruby DBI it'd be something like this: > > @handle.do("INSERT INTO user_data SET marshal=?", d) > > See if the same works on your setup. Parameter binding should be > supported by all decent database libraries, so there'll be a way to do > it. If not, then there has to be an escaping/quotation method to get > the data in ;-) > > Cheers, > Peter Cooper > http://www.rubyinside.com/ I'm using the mysql library for Ruby. Not sure about the paramter binding.. but Base64.b64encode and Base64.decode64 works fine. Thanks -- Posted via http://www.ruby-forum.com/.