pygresql - bytea

Christoph Zwerschke cito at online.de
Sun May 7 08:50:04 EDT 2006


Jan Danielsson wrote:
>    I'm trying to use pygresql to insert binary data (type: bytea) into a
> column (using postgresql, obviously).
 > ...
>    Does _anyone_ have a working example? A simple insertion, and a
> simple select is all I'm looking for.

You should better ask such questions on the PyGreSQL mailing list.

Actually, you can insert and delete bytea data just as you would insert 
and select ordinary string data, with the exception that you have to 
escape the data before the insert, and unescape after select.

For instance, the string 'a\x00b' must be inserted as 'a\\000b'. As a 
result from a select, you will get 'a\000b'.

The next PyGreSQL version will have functions for escaping and 
unescaping on board (they are already checked in to CVS).

-- Christoph



More information about the Python-list mailing list