Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id CD19AB5DBCA for ; Fri, 1 Jul 2011 07:27:42 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 17202-02 for ; Fri, 1 Jul 2011 10:27:36 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from delta01.pnet.xcon.it (delta01.pnet.xcon.it [62.48.53.16]) by mail.postgresql.org (Postfix) with ESMTP id 2B620B5DBC1 for ; Fri, 1 Jul 2011 07:27:35 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by delta01.pnet.xcon.it (Postfix) with ESMTP id A0FE410336FBB; Fri, 1 Jul 2011 12:27:34 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at delta01.pnet.xcon.it Received: from delta01.pnet.xcon.it ([127.0.0.1]) by localhost (delta01.pnet.xcon.it [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Pnx7fGdigPpH; Fri, 1 Jul 2011 12:27:31 +0200 (CEST) Received: from webmail.xcon.it (unknown [62.48.53.98]) (Authenticated sender: gabriele.bartolini@2ndquadrant.it) by delta01.pnet.xcon.it (Postfix) with ESMTPSA id CCEE810337017; Fri, 1 Jul 2011 12:27:31 +0200 (CEST) Received: from eggIB-wan.comune.prato.it ([193.43.108.2]) by webmail.xcon.it with HTTP (HTTP/1.1 POST); Fri, 01 Jul 2011 12:27:31 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 01 Jul 2011 12:27:31 +0200 From: Gabriele Bartolini To: Cc: Subject: Re: Import image into postgresql database In-Reply-To: <8011192.5657131309515213054.JavaMail.defaultUser@defaultHost> References: <8011192.5657131309515213054.JavaMail.defaultUser@defaultHost> Message-ID: <66e9969ab6c632e91670fc4612beffba@2ndquadrant.it> X-Sender: Gabriele.Bartolini@2ndQuadrant.it User-Agent: [X]con Webmail/0.4.2 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201107/5 X-Sequence-Number: 37784 Ciao Francesco, On Fri, 1 Jul 2011 12:13:33 +0200 (CEST), "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