Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Anyone using SPOPS to store BLOBs?

by lachoy (Parson)
on Jun 25, 2003 at 02:48 UTC ( #268735=note: print w/replies, xml ) Need Help??

in reply to Anyone using SPOPS to store BLOBs?

You can access TEXT fields normally, but it may be the case that once you stuff n characters in the field it becomes a blob stored outside the table. (Do a '\dl' in psql to get a listing of all LOBs stored in the db.)

Looking at the DBD::Pg docs you need special operations to work with LOBs. (Fortunately for framework authors, these operations vary from database to database...) You can either read it in all at once or a chunk at a time, both using the blob_read function of the statement handle.

What I'd do is handle it outside of SPOPS entirely. If this is the only field in the table then probably wouldn't use SPOPS for the table. If you do use it SPOPS can be told to only deal with certain fields of a table by listing the fields in the 'field' configuration key. Just don't list your PDF field there and create a method (likely inherited or delegated since it should be a fairly generic operation) to use the DBD::Pg functionality to stream the LOB into a file. Then you have no memory worries and can use SPOPS normally.

Hope this makes sense.

M-x auto-bs-mode

Replies are listed 'Best First'.
Re: Re: Anyone using SPOPS to store BLOBs?
by talexb (Chancellor) on Jun 25, 2003 at 14:35 UTC

    After some experimentation and some RTFM-ing I realized that of course I wanted 'bytea' fields instead of 'text' fields.

    Currently we use a Documents table with a bunch of information in it as part of our system; including the file itself would smooth a lot of things out -- we'd have to copy the file from Postgres to the file system for processing but (this is the cool part that I love) any files that were created during processing can then be stored back into the database. This means that we have the ability to back-track to previous iterations. (For obvious reasons, I can't describe my system in a lot of detail.)

    Your advice (third paragraph) does make sense .. thanks for the pointers. I'll be reading up on SPOPS more this week to see if we can fit your wheel in somewhere rather than build our own.

    --t. alex
    Life is short: get busy!

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://268735]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2022-05-21 06:55 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (76 votes). Check out past polls.