If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > blob-postgres

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-27-11, 00:54
flightline flightline is offline
Registered User
 
Join Date: Mar 2011
Posts: 3
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
Reply With Quote
  #2 (permalink)  
Old 03-27-11, 03:32
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
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.
Reply With Quote
  #3 (permalink)  
Old 03-27-11, 06:23
flightline flightline is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 03-27-11, 06:37
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Text strings should not be stored in a bytea column, but in a text column.

Quote:
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.

Quote:
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 06:41.
Reply With Quote
  #5 (permalink)  
Old 03-27-11, 06:54
flightline flightline is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On