pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Premsun Choltanwanich <Premsun@nsasia.co.th>
To: getsreejith@gmail.com
To: pgsql-sql@postgresql.org
To: lawgon@thenilgiris.com
Subject: Re: Image Insert Postgresql DB
Date: Tue, 23 Nov 2004 14:18:00 +0700
Message-ID: <s1a346c8.046@jupiter.nsasia.co.th> (raw)

I face this same problem when I try to insert image by lo_import to
database with my client files. I already change the way to bytea data
type but it's not work. The error return like type mismatch when I try
to insert it from Binary variable.

Why I cannot insert it? If anybody found some solution please reply on
this topic for me too.

Thank You.


>>> Kenneth Gonsalves <lawgon@thenilgiris.com> 23/11/2004 12:18:44 pm
>>>



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

---------------------------(end of
broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org



view thread (8+ messages)  latest in thread

Message-ID: <s1a346c8.046@jupiter.nsasia.co.th>
Permalink:  ../s1a346c8.046@jupiter.nsasia.co.th/
Also on:    postgresql.org/message-id/s1a346c8.046@jupiter.nsasia.co.th

 · 

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-sql@postgresql.org
  Cc: Premsun@nsasia.co.th, getsreejith@gmail.com, lawgon@thenilgiris.com
  Subject: Re: Image Insert Postgresql DB
  In-Reply-To: <s1a346c8.046@jupiter.nsasia.co.th>

* 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