[Gambas-user] Q:how to save a file.png into Postgresql

Stephen Bungay sbungay at ...981...
Fri Aug 29 06:24:14 CEST 2008


   Just because something can be done one has to ask the question should 
it be done?
   While saving things like PNG or audio files in a database certainly 
has the appeal of convenience, over the long-haul such a practice may 
end up coming back to haunt the programmer/designer.
   File systems are very good at storing and organizing... well... 
files. Relational databases are very good at storing and retrieving 
information that is not well suited to raw file systems.
   In my experience (and I can only speak for myself) the use of a 
database to store a the path and filename, but not the actual file, puts 
the tools at our disposal to good effective use, essentially allowing 
the programmer to index the file system within the database.
   Storing Large Binary objects in a database can negatively impact 
caching (and therefore overall database performance). On the other hand, 
storing the file names and locations as simple text strings allows the 
programmer to treat the data as a pointer and pass the "pointer" to 
other more specialized programs. The image-viewers, audio players, or 
what-have-you, are then left to do what they do best, deal with the 
files they are pointed at.
   I know I didn't answer your question, I'm not all that familiar with 
Postgres. Some quick googling finds that bytea, large object, and text 
can all store 2GB... with different performance hits, limitations, and 
general "gotchas".

Steve.

richard terry wrote:
> I've adapted the IDE icon editor to load my own pictures in my program, draw 
> on them and save the file, but now need to save the result to disk.
> 
> Two options.
> 1) Save the changed diagram.
> 2) or somehow just save the changed bits of the picture - perhaps one can just 
> paint on a transparent overlay? I've no idea.
> 
> Anway, as an interim step I wondered if anyone could give me a line of sql 
> code to insert a picture into postgres. I looked at the docs and the nearest 
> I could think was maybe using the bytea type of data field.
> 
> Any  help appreciated.
> 
> Thanks
> 
> Richard
> 
> 
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 





More information about the User mailing list