Re: Import file into bytea field in SQL/plpgsql?

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: Import file into bytea field in SQL/plpgsql?
Дата
Msg-id 47CE65E6.904@archonet.com
обсуждение исходный текст
Ответ на Import file into bytea field in SQL/plpgsql?  (Erwin Brandstetter <brsaweda@gmail.com>)
Список pgsql-general
Erwin Brandstetter wrote:
> Hi!
>
> What I want to do:
> Import a file from the file system into a bytea field of a table.

> Now, I could copy over from pg_largeobject:

> And create a large object and export from there as above.
> But that seems unnecessarily complex, and  .. well .. stupid.
>
> There must be a simpler way to import/export a file (as a whole, an
> image for instance) into/out of my bytea field - in SQL or plpgsql?
> Probably another set of functions I overlooked?

Not that I know of. It's simple enough to do from the application side
of things of course (well, in most languages) but there's no general
file access.

You can do various tricks to grab text values (see psql in the docs "SQL
Interpolation") but you'd need to escape the values. Not sure that's any
cleaner than the large-object approach.

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: Meaning og Logs
Следующее
От: Emmanuel Quevillon
Дата:
Сообщение: Terminal completion