Re: Emitting JSON to file using COPY TO

From: Dominique Devienne <ddevienne(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Davin Shearer <scholarsmate(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Emitting JSON to file using COPY TO
Date: 2023-11-27 09:33:00
Message-ID: CAFCRh-_LhP5Ln4-beVz=1pQ9VycU3hAxnJHXhPHZRmX0BSCVEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Sat, Nov 25, 2023 at 10:00 PM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 11/25/23 11:21, Davin Shearer wrote:
> > Hello!
> >
> > I'm trying to emit a JSON aggregation of JSON rows to a file using COPY
> > TO, but I'm running into problems with COPY TO double quoting the
> > output. Here is a minimal example that demonstrates the problem I'm
> > having:
> >
>
> > I have tried to get COPY TO to copy the results to file "as-is" by
> > setting the escape and the quote characters to the empty string (''),
> > but they only apply to the CSV format.
> >
> > Is there a way to emit JSON results to file from within postgres?
> > Effectively, nn "as-is" option to COPY TO would work well for this JSON
> > use case.
> >
>
> Not using COPY.
>
> See David Johnson's post for one way using the client psql.
>
> Otherwise you will need to use any of the many ETL programs out there
> that are designed for this sort of thing.
>

Guys, I don't get answers like that. The JSON spec is clear:

>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Dominique Devienne 2023-11-27 09:44:55 Re: Emitting JSON to file using COPY TO
Previous Message Dominique Devienne 2023-11-27 09:29:46 Re: How to eliminate extra "NOT EXISTS"-query here?

Browse pgsql-hackers by date

  From Date Subject
Next Message Dominique Devienne 2023-11-27 09:44:55 Re: Emitting JSON to file using COPY TO
Previous Message Ashutosh Bapat 2023-11-27 09:24:28 Re: How to get started with contributions