Re: Inserting .png file into bytea column

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Inserting .png file into bytea column
Дата
Msg-id n2l84p$jae$1@ger.gmane.org
обсуждение исходный текст
Ответ на Inserting .png file into bytea column  ("Ferrell, Denise D CTR NSWCDD, H11" <denise.ferrell.ctr@navy.mil>)
Список pgsql-admin
Ferrell, Denise D CTR NSWCDD, H11 schrieb am 19.11.2015 um 15:07:
> Good Morning All,
>
> I am using PostgreSQL 9.3 on Linux Rehat...
>
> I'm trying to insert an image (.png format) into a table of flags.  I've tried the following but keep getting errors.
>
> CREATE TABLE FLAGS (country_code text, flag bytea);
>
> INSERT INTO flags VALUES ('AD', pg_read_file('/home/flags')::bytea);
>
> Get the following error:
> ERROR:   absolute path not allowed
> *********ERROR*************
> ERROR:  absolute path not allowed
> SQL State:  42501
>
> Any assistance would be greatly appreciated.
>
> Denise Ferrell
>

If the image is on the computer where the SQL client is running, pg_read_file() can not be used
because it is reading files on the server, not the client.

If you are open to a different SQL client, the one I am maintaining - SQL Workbench/J - can
do precisely what you want:

     INSERT INTO flags VALUES ('AD', {$blobfile=/home/flags});

This will read the file from the computer where SQL Workbench is running:

But again: this syntax *only* works with SQL Workbench/J

   http://www.sql-workbench.net/blob_example.html

You can also do this directly from within a result of a SELECT statement:

    http://www.sql-workbench.net/BlobDisplay_png.html

Full disclosure: I am the author of that tool.

Thomas


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

Предыдущее
От: Dorian Machado
Дата:
Сообщение: Re: Inserting .png file into bytea column
Следующее
От: Wei Shan
Дата:
Сообщение: Re: Different versions between psq/postgres and the actual database