Re: Emitting JSON to file using COPY TO

Поиск
Список
Период
Сортировка
От Davin Shearer
Тема Re: Emitting JSON to file using COPY TO
Дата
Msg-id CALvfUkCq3pvkmniWEKZwkbA6hNNvkANF3OamMfhC170RgY+HJg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Emitting JSON to file using COPY TO  (Filip Sedlák <filip@sedlakovi.org>)
Список pgsql-general
Thanks for the responses everyone.

I worked around the issue using the `psql -tc` method as Filip described.

I think it would be great to support writing JSON using COPY TO at some point so I can emit JSON to files using a PostgreSQL function directly.

-Davin

On Tue, Nov 28, 2023 at 2:36 AM Filip Sedlák <filip@sedlakovi.org> wrote:
This would be a very special case for COPY. It applies only to a single
column of JSON values. The original problem can be solved with psql
--tuples-only as David wrote earlier.


$ psql -tc 'select json_agg(row_to_json(t))
              from (select * from public.tbl_json_test) t;'

  [{"id":1,"t_test":"here's a \"string\""}]


Special-casing any encoding/escaping scheme leads to bugs and harder
parsing.

Just my 2c.

--
Filip Sedlák

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

Предыдущее
От: Chris Travers
Дата:
Сообщение: Re: Fixing or Mitigating this ERROR: invalid page in block 35217 of relation base/16421/3192429
Следующее
От: Sri Mrudula Attili
Дата:
Сообщение: Re: Could not read from file "pg_subtrans/00F5" at offset 122880: Success.