Skip site navigation (1) Skip section navigation (2)

Re: Image Insert Postgresql DB

From: Kenneth Gonsalves <lawgon(at)thenilgiris(dot)com>
To: sreejith s <getsreejith(at)gmail(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Image Insert Postgresql DB
Date: 2004-11-23 05:18:44
Message-ID: (view raw, whole thread or download thread mbox)
Lists: 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


In response to

pgsql-sql by date

Next:From: sreejith sDate: 2004-11-23 06:50:30
Subject: Image Insert Doubt
Previous:From: Vishal Kashyap @ [SaiHertz]Date: 2004-11-23 04:37:22
Subject: Re: Image Insert Postgresql DB

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group