pygresql - bytea

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jan Danielsson

    #1

    pygresql - bytea

    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.

    --
    Kind Regards,
    Jan Danielsson
    Te audire non possum. Musa sapientum fixa est in aure.
  • Christoph Zwerschke

    #2
    Re: pygresql - bytea

    Jan Danielsson wrote:[color=blue]
    > 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.[/color]

    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

    Comment

    Working...