Martin Kaletsch wrote:

> 
> Hello!
> 
> I don't know if I just don't get it, but are there any functions encoding
> binary data for inserting into bytea columns in a postgresql db? All I
> found in dbi (0.0.23) and ruby-postgres (0.7.1) seems rather low-level.
> Does anybody have an example handy, or should I do the escapes by hand?
> 
> --
> Martin Kaletsch

The ruby postgres library has what you need, though it doesn't seem to be
documented.  PGconn has the following class methods:
["escape_bytea", "connect", "setdb", "quote", "escape", "setdblogin"]

I think PGconn.escape_bytea is what you want.  Pass it your binary data as an
argument and you'll get back an escaped string to send to the DB.  Don't
forget to quote the result.

Luca