pygresql - bytea

J

Jan Danielsson

Hello all,

I'm trying to use pygresql to insert binary data (type: bytea) into a
column (using postgresql, obviously).

To make a long story short: I can't get it to work. Not even by
cutting and pasting the very few examples I have found on the 'net.

Does _anyone_ have a working example? A simple insertion, and a
simple select is all I'm looking for.
 
C

Christoph Zwerschke

Jan said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top