Re: R: Re: Import image into postgresql database

From: David Hornsby <david(at)beechglen(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: R: Re: Import image into postgresql database
Date: 2011-07-11 14:26:18
Message-ID: 4E1B080A.3010803@beechglen.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

The best way I found is to just treat the image as a BLOB. Create a
column with type OID and do a lo_import and an lo_export as demonstrated
in this page.
http://www.postgresql.org/files/documentation/books/aw_pgsql/node96.html

-David.

On 7/1/11 8:30 AM, francescoboccacci(at)libero(dot)it wrote:
> Thanks,
>
> Francesco
>
>> ----Messaggio originale----
>> Da: Gabriele(dot)Bartolini(at)2ndQuadrant(dot)it
>> Data: 01/07/2011 12.27
>> A:<francescoboccacci(at)libero(dot)it>
>> Cc:<pgsql-admin(at)postgresql(dot)org>
>> Ogg: Re: [ADMIN] Import image into postgresql database
>>
>> Ciao Francesco,
>>
>> On Fri, 1 Jul 2011 12:13:33 +0200 (CEST), "francescoboccacci(at)libero(dot)it"
>> <francescoboccacci(at)libero(dot)it> wrote:
>>> I tried to insert in both ways. With oid type i able to insert
>>> images, but
>>> with bytea i don't understand how store it .
>> I would definitely suggest to use 'bytea' column rather than large
>> objects support in PostgreSQL, as it is much simpler to manage.
>>
>>> INSERT INTO images (img) VALUES (pg_escape_bytea('C:\\9999.jpg'))
>> bytea is an array of bytes, it is like a binary string. You must
>> provide directly the binary content yourself in your SQL query
>> (PostgreSQL does not have a clue about where your locale file is).
>>
>> Loading must be performed at client level, using your favourite
>> application language, then passed to PostgreSQL. Every major language
>> now is able to deal with PostgreSQL's bytea type transparently.
>> Otherwise, you can still do it yourself, by properly formatting every
>> input byte in your SQL query using the format described here:
>> http://www.postgresql.org/docs/9.0/static/datatype-binary.html
>>
>>> but it doesn't work.
>>> So How can i solve my problem? and another question.. If i able to
>>> store my
>>> image into bytea fiels..how can i export it for see it for example
>>> with paint?
>> You still have to think in terms of binary information, sequences of
>> bytes. Your application might return it via the web (typical case) or
>> save it locally in a temporary folder for display.
>>
>> Ciao,
>> Gabriele
>>
>> --
>> Gabriele Bartolini - 2ndQuadrant Italia
>> PostgreSQL Training, Services and Support
>> Gabriele(dot)Bartolini(at)2ndQuadrant(dot)it - www.2ndQuadrant.it
>>
>> --
>> Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-admin
>>
>
>

--
David Hornsby

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Kevin Grittner 2011-07-11 19:37:21 Re: row is too big during cluster
Previous Message Devrim GÜNDÜZ 2011-07-11 12:57:06 Re: Trying to download pgpool but found the site is down :-(