Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 400C2B5DBC8 for ; Fri, 1 Jul 2011 09:30:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 63256-05 for ; Fri, 1 Jul 2011 12:30:44 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from outrelay03.libero.it (outrelay03.libero.it [212.52.84.103]) by mail.postgresql.org (Postfix) with ESMTP id 5FD7EB5DBC1 for ; Fri, 1 Jul 2011 09:30:44 -0300 (ADT) X-CTCH-Spam: Unknown X-CTCH-RefID: str=0001.0A0B0203.4E0DBDF2.024A,ss=1,re=0.000,fgs=0 X-libjamoibt: 1821 Received: from wmail5.libero.it (172.31.0.148) by outrelay03.libero.it (8.5.133) (authenticated as francescoboccacci@libero.it) id 4DE4FF1D01D72F3D; Fri, 1 Jul 2011 14:30:42 +0200 Message-ID: <2221885.5950861309523442924.JavaMail.root@wmail5.libero.it> Date: Fri, 1 Jul 2011 14:30:42 +0200 (CEST) From: "francescoboccacci@libero.it" Reply-To: "francescoboccacci@libero.it" To: Subject: R: Re: Import image into postgresql database Cc: MIME-Version: 1.0 Content-Type: text/plain;charset="UTF-8" Content-Transfer-Encoding: 7bit X-SenderIP: 213.182.95.210 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201107/7 X-Sequence-Number: 37786 Thanks, Francesco >----Messaggio originale---- >Da: Gabriele.Bartolini@2ndQuadrant.it >Data: 01/07/2011 12.27 >A: >Cc: >Ogg: Re: [ADMIN] Import image into postgresql database > > 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 > >-- >Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) >To make changes to your subscription: >http://www.postgresql.org/mailpref/pgsql-admin >