From: John Pritchard-williams Date: 2008-09-01T18:04:50+09:00 Subject: Re: Problems inserting PDF (Blob) to Mysql DB Hi Rodrigo, Are you able to try the SQL directly against your MySQL db for a test ? Might be worth doing something like: 1. First just confirm you are able to insert a simple 'text' file into the DB using this sql. (....'recbibo')...VALUES (...'This is my text file\ndoes this work?\n"); 2. Then move onto a (small) PDF (or other binary) file: perhaps 'dress' up the binary file (edit it like a text file) and add the SQL round it ? I'm just wondering whether this is really a Ruby issue or not ? (more to do with mysql SQL syntax ?) Cheers John Rodrigo Bermejo wrote: > > Hi List /. > > I need to insert a PDF file as a Blob to a Mysql DB. > > I'm doing something like this: > > f=File.open(x).read > insert=%^INSERT INTO `main_recibos` > ( `recibo_id`, `sso` , `periodo` , `recibo` ) > VALUES > ( '#{recibo_id}' , '#{sso}', #{periodo}, '#{f}' ); ^ > @mysql.query(insert) > > But I am getting 'Please check the syntax of your SQL' > And the error seems created by the funny chars on the binary data. > I've already tried escaping in many ways the data with out success. > > > Any idea how to get rid of this error /? > > Thank you -- Posted via http://www.ruby-forum.com/.