Re: insert binary data into a table column with psql

Поиск
Список
Период
Сортировка
От Lonni J Friedman
Тема Re: insert binary data into a table column with psql
Дата
Msg-id CAP=oouEeX5hf-+Y4Y0ZB9OGiBHYLw8qKYVfQ_SV0PJFbs_BrQQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: insert binary data into a table column with psql  (John R Pierce <pierce@hogranch.com>)
Список pgsql-general
On Tue, Jul 24, 2012 at 2:22 PM, John R Pierce <pierce@hogranch.com> wrote:
> On 07/24/12 1:28 PM, jkells wrote:
>>
>> from psql
>> I have tried several ways including creating a function to read a file
>> without any success but basically I want to do something like the
>> following from a bash shell
>>
>> psql <connection information> -c "insert into x (ID, load_date, image)
>> values ($PID,clock_timestamp()::timestamp(0), copy from '/tmp/$FN' with
>> binary);"
>>
>> Any help would be greatly appreciated
>
>
> use a proper programming language that can read files and insert BYTEA data.
> shell + psql just won't cut it.   I'd suggest perl or python or java or

Actually, that's not true.  Its definitely possible to INSERT data
into bytea using just psql.  The trick is to sub- 'select' the data
with the bytea_import function in the INSERT.  So something like this:
insert into x (ID, load_date, image)
values ($PID,clock_timestamp()::timestamp(0), (SELECT bytea_import(
'/tmp/$FN'));"

В списке pgsql-general по дате отправления:

Предыдущее
От: Edson Richter
Дата:
Сообщение: Re: Pg 9.1: Do I need to run vacuum analyze instead vacuum full?
Следующее
От: Anthony Bull
Дата:
Сообщение: Re: Pg 9.1: Do I need to run vacuum analyze instead vacuum full?