From: | Szymon Guz <mabewlun(at)gmail(dot)com> |
---|---|
To: | David Rysdam <drysdam(at)ll(dot)mit(dot)edu> |
Cc: | PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: I want the stupidest possible binary export |
Date: | 2014-09-18 14:21:55 |
Message-ID: | CAFjNrYvmy7CaPv6Cb9UGy4ZEje85NkxYCyn4mT0+VfKys7QLZA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 18 September 2014 16:06, David Rysdam <drysdam(at)ll(dot)mit(dot)edu> wrote:
> I've got a some tables with bytea fields that I want to export only the
> binary data to files. (Each field has a gzipped data file.)
>
> I really want to avoid adding overhead to my project by writing a
> special program to do this, so I'm trying to do it from psql. Omitting
> the obvious switches for username, etc, here's what I'm doing:
>
> psql -t -c "\copy (select mybinaryfield from mytable where key = 1) to
> 'file'"
>
> That works, but I get escaped bytes. I want actual binary directly out
> of the DB. Another option might be:
>
> psql -t -c "\copy (select mybinaryfield from mytable where key = 1) to
> 'file'" with format binary
>
> However, there are two problems. First, I get an syntax error "at or
> near 'format'". (Running 9.2 client and server.) And second, I suspect
> that'll be some "proprietary" PG format, not the actual bytes from just
> my field.
>
> What option am I missing?
>
>
>
>
Hi,
first of all "with format binary" must be a part of the -c command, not
part of the shell command.
I don't know why this doesn't work:
psql -t -c "\copy (select mybinaryfield from mytable where key = 1) to
'file' with format binary "
but this works for me:
psql -t -c "\copy (select mybinaryfield from mytable where key = 1) to
'file' binary "
regards,
Szymon
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2014-09-18 14:24:05 | Re: I want the stupidest possible binary export |
Previous Message | David Rysdam | 2014-09-18 14:06:35 | I want the stupidest possible binary export |