Re: [OT] PostgreSQL: bytea help needed.

From: Mike Cox (mikecoxlinux_at_yahoo.com)
Date: 02/03/05


Date: 03 Feb 2005 13:10:27 -0800

Christopher Browne <cbbrowne@acm.org> writes:

> Centuries ago, Nostradamus foresaw when Mike Cox <mikecoxlinux@yahoo.com> would write:
> > Does anyone know how to add data to a bytea in PostgreSQL? I googled
> > the archives, and they mostly talk about PHP. I'd like to put binary
> > data in the bytea from my local filesystem, but google comes up empty
> > other than using PHP.
>
> Well, you draw the data in, and then append it to the field.

Well this is elementary stuff. Lets say I wanted to pull a jpg into
the database from my local filesystem for example. How would what you
just wrote help me in this regard? I already know how to append to a
bytea from within the database and using an interface like JDBC, but
what about the psql terminal?

> tutorial=# create table ba1 (stuff bytea);
> CREATE TABLE
> tutorial=# insert into ba1 values ('foo');
> INSERT 2749794 1
> tutorial=# update ba1 set stuff = stuff || ' more stuff';
> UPDATE 1
> tutorial=# select * from ba1;
> stuff
> ----------------
> foo more stuff
> (1 row)
>
> Your application needs to be in some language; that presumably needs
> to be where the data is loaded from disk into a variable. You would
> then push the variable into the update query.
>
> When you were googling, you mostly found PHP details; can you suggest
> details about what language you're planning to use instead, be that
> Perl, C, Python, Java, or such?

Well I wanted to grab binary data off my filesystem directly from the
psql terminal. Something like lo_import that is used for BLOBS or the
COPY command which is used to pull text data in.

I know how to pull data from Java and those other interfaces, but then
I'd have to get JDBC or install Apache, PHP etc. I want to be able
to, like I posted, be able to do this within the psql terminal.
 
> This isn't really a Linux question, by the way...

There are *no* postgresql usenet newsgroups. Not a one. There are
mailing lists gated to the pgsql hierarchy, but one needs to subscribe
to the mailing list in order to post. Even if one elects not to get emails,
many people will email you regardless by changing some settings in
their mailing client.

The NAN moderators are dragging their feet about getting a PostgreSQL
CFV through. So people who need help are forced to seek it where
there may be a PostgreSQL user, like in the linux group. There is
certainly an overlap between Linux users and PostgreSQL users.



Relevant Pages

  • pygresql - bytea
    ... I'm trying to use pygresql to insert binary data (type: bytea) into a ... column (using postgresql, obviously). ...
    (comp.lang.python)
  • Re: PostgreSQL
    ... Robert L Cochran wrote: ... > If you need to work with BLOBs, be aware that PostgreSQL doesn't have a ... > BLOB data type. ... Postgres has bytea and a large object type. ...
    (Fedora)
  • DBForms from MSAccess to PHP+PostgreSQL 1.0.0
    ... DBForms from MS Access to PHP + PostgreSQL is an application to ... several stages so the most complex issues of the conversion are broken ...
    (comp.software.shareware.announce)
  • Re: [OT] PostgreSQL: bytea help needed.
    ... > Does anyone know how to add data to a bytea in PostgreSQL? ... and they mostly talk about PHP. ... > data in the bytea from my local filesystem, but google comes up empty ... tutorial=# create table ba1; ...
    (comp.os.linux.misc)
  • RE: Witch database do you recommend?
    ... then you should probably use PostgreSQL as it's SQL functionality fully ... those on google) and there is no general answer to your question. ... |>> to be great, the mailing lists great, and just getting it working ... To unsubscribe, ...
    (freebsd-questions)