Re: Image Insert Postgresql DB - Mailing list pgsql-sql

From Kenneth Gonsalves
Subject Re: Image Insert Postgresql DB
Date
Msg-id 0411231048440L.01150@thenilgiris.com
Whole thread Raw
In response to Image Insert Postgresql DB  (sreejith s <getsreejith@gmail.com>)
List pgsql-sql


On Tuesday 23 November 2004 09:51 am, sreejith s wrote:

> Query to insert
> ----------------
> INSERT INTO Imagetable VALUES (lo_import('C:\\image\\peach.jpg'));


have you succeeded in inserting an image into the database from a file on the 
server using the above query? AFAIK you need a bytea datatype, and also the 
image data has to be properly escaped (\\) before pg will accept it. I assume 
you are using a scripting language with a dbapi. Your steps would be:

1. read the image file into a variable
2. escape the image data
3. insert this into the database in a bytea field

if you follow this procedure it is irrelevant as to where the source file is 
- client or server

regards
kg


pgsql-sql by date:

Previous
From: "Vishal Kashyap @ [SaiHertz]"
Date:
Subject: Re: Image Insert Postgresql DB
Next
From: sreejith s
Date:
Subject: Image Insert Doubt