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

richard terry rterry at ...1946...
Fri Aug 29 06:49:38 CEST 2008

On Fri, 29 Aug 2008 02:24:14 pm Stephen Bungay wrote:
>    Just because something can be done one has to ask the question should
> it be done?
Thanks stephen for your reply.

This is a mission-critical database - its an updated version of my medical 
records program which I've used for 10 years, I'm re-writing for linux. 
Mission-critical and medico-legal. 

The files are only 2k each for simple sketches, larger of course when I get 
around to saving photo's of skin lesions.  In my old program I did exactly as 
you say - stored the name/path of the files, but in this one I want to (at 
least attempt) to save the file into the database for back-up purposes. Daily 
database backups are probably less likely to lose data than files exposed to 
the native file-system with inadvertant deletion possible.

I have looked at the bytea - I just cannot interpret how to use it, or to know 
how to start in gambas.



>    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