pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gabriele Bartolini <Gabriele.Bartolini@2ndQuadrant.it>
To: francescoboccacci@libero.it
Cc: pgsql-admin@postgresql.org
Subject: Re: Import image into postgresql database
Date: Fri, 01 Jul 2011 12:27:31 +0200
Message-ID: <66e9969ab6c632e91670fc4612beffba@2ndquadrant.it> (raw)
In-Reply-To: <8011192.5657131309515213054.JavaMail.defaultUser@defaultHost>
References: <8011192.5657131309515213054.JavaMail.defaultUser@defaultHost>

 Ciao Francesco,

 On Fri, 1 Jul 2011 12:13:33 +0200 (CEST), "francescoboccacci@libero.it" 
 <francescoboccacci@libero.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.Bartolini@2ndQuadrant.it - www.2ndQuadrant.it



view thread (2+ messages)

Message-ID: <66e9969ab6c632e91670fc4612beffba@2ndquadrant.it>
Permalink:  ../66e9969ab6c632e91670fc4612beffba@2ndquadrant.it/
Also on:    postgresql.org/message-id/66e9969ab6c632e91670fc4612beffba@2ndquadrant.it

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: Gabriele.Bartolini@2ndQuadrant.it, francescoboccacci@libero.it
  Subject: Re: Import image into postgresql database
  In-Reply-To: <66e9969ab6c632e91670fc4612beffba@2ndquadrant.it>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox