pygresql - bytea

Discussion in 'Python' started by Jan Danielsson, Apr 27, 2006.

  1. 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.
     
    Jan Danielsson, Apr 27, 2006
    #1
    1. Advertising

  2. 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
     
    Christoph Zwerschke, May 7, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ravi
    Replies:
    0
    Views:
    477
  2. Steve

    Postgres BYTEA problems

    Steve, Mar 3, 2004, in forum: Python
    Replies:
    1
    Views:
    734
    Ivan Voras
    Mar 4, 2004
  3. Morten Goodwin Olsen

    Python, PostgreSQL and bytea

    Morten Goodwin Olsen, Sep 8, 2004, in forum: Python
    Replies:
    4
    Views:
    2,446
    Stuart Bishop
    Sep 15, 2004
  4. George Sakkis
    Replies:
    1
    Views:
    433
    George Sakkis
    May 23, 2008
  5. Replies:
    0
    Views:
    1,090
Loading...

Share This Page