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

Re: Binary data in PostgreSQL

From: "Bas Scheffers" <bas(at)scheffers(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: holger(at)marzen(dot)de
Subject: Re: Binary data in PostgreSQL
Date: 2004-02-22 10:09:41
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-general
Although I am not using it for massive files (small jpegs with people's
mugshots) I have been storing them in a bytea column without problems.

I am using Tcl in AOLserver and it is easy to insert and retrieve the
files. To insert/update, you use hex encoded files, so simply do:
"binary scan $binaryString H* hexdata" to get the hex string and in the
SQL you simply use "decode('$hexdata', 'hex')" as value.

When you retrieve the data, the encoding is a bit, well, weird. (see the
manual) but because it is using backslash escaping of special character
into they ascii values, in Tcl it is dead easy to convert back to binary
set bindata [subst -novariables -nocommands $pgdata].

Hope that helps,

pgsql-general by date

Next:From: Gary DoadesDate: 2004-02-22 10:36:47
Subject: Re: Slow queries in PL/PGSQL function
Previous:From: Jonathan BartlettDate: 2004-02-22 05:50:33
Subject: Re: Binary data in PostgreSQL

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