Results 1 to 5 of 5

Thread: blob-postgres

  1. #1
    Join Date
    Mar 2011
    Posts
    3

    Unanswered: blob-postgres

    hi, my first post !
    blobs with postgres seem difficult. tried bytea - too many hassles and too slow. any vb6 code exampled to store images as LOBs ? I also want to store
    binary files.

    Postgres doc seems to point out that the client can 'NEVER' use lo_import?
    What does this mean? and what's the use of the LOB in that case?

    I was able to store a few files on the server [localhost] but the same code failed completely on a client [ODBC connection ]. it's driving me loony

    any help is welcome - cheers

    rgards
    francis

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    I don't use VBA but I have no problems using bytea with Java/JDBC. And I never noticed that they are slow (btw: slow compared to what?)

    I can't comment on large objects because I have never used them, but the manual clearly states that lo_import() is usable on the client.

    From: http://www.postgresql.org/docs/9.0/static/lo-interfaces.html
    Quote Originally Posted by Manual for lo_import
    Note that the file is read by the client interface library, not by the server; so it must exist in the client file system and be readable by the client application.

  3. #3
    Join Date
    Mar 2011
    Posts
    3

    Lob

    Thanks Shammat

    Good to hear bytea works - am i correct in inferring that strings need to be reworked to ensure funny ascii sequences are not included? suppose
    it's a text string - no problem. If it's an image that has a few contiguous bytes which are ascii 0 or ascii 255 what happens. An image may have
    several hundred bytes like this. The manual says to use escape sequences

    The LOB issue is serious. Any example code [any language] will help
    I stored a few LOBs on localhost - was also able to retreive them

    However the moment I am on another networked machine [ODBC] this fails

    What's the hitch?

    Here's the line from the manual
    Large Objects (BLOBs)

    Quote:
    Full path names must be used with large objects because the database server runs in a different directory than the psql client. Files are imported and exported by the postgres user, so postgres must have permission to read the file for lo_import() and directory write permission for lo_export(). Because large objects use the local filesystem, users connecting over a network cannot use lo_import or lo_export(). They can, however, use psql's \lo_import and \lo_export commands.

    What the dickens does this mean??

    lo_write and lo_import does not work!

    is another guy suffering. I'm heading for a minor 'eart attack

    Anyways do let me know how successful your bytea is with binary strings with
    peculiar non UTF-8 sequences.

  4. #4
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Text strings should not be stored in a bytea column, but in a text column.

    Here's the line from the manual Large Objects (BLOBs)
    That link is completely outdated (it's from 2002!!!) and the statements in there might have been correct for ancient (and discontinued) versions of Postgres but are definitely wrong for any up-to-date version (8.3 or above).
    Please use the official manual: http://www.postgresql.org/docs/current/static/index.html

    I only using Java/JDBC to access Postgres and I never had to worry about escaping or anything like that for bytea columns. I simply pass a byte array (or a byte stream) to the JDBC statement object and everything else is taken care of by the driver.

    I would be surprised if there wasn't something similar for ODBC.

    The LOB issue is serious. Any example code [any language] will help
    I stored a few LOBs on localhost - was also able to retreive them
    The documentation for the JDBC driver contains examples for both (bytea and LO):
    http://jdbc.postgresql.org/documentation/head/binary-data.html
    Last edited by shammat; 03-27-11 at 07:41.

  5. #5
    Join Date
    Mar 2011
    Posts
    3

    bytea

    oops - thanks for pointing it out shammat

    will try immediately - if it works i owe you a drink alright

    i especially like to work with vb for quick solutions
    any vb code would be great

    'eart attack postponed !!

    regs
    francis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •