Re: Emitting JSON to file using COPY TO - Mailing list pgsql-general

From Adrian Klaver
Subject Re: Emitting JSON to file using COPY TO
Date
Msg-id fc1e39f8-274f-4be6-8a70-9fb0d9fe84a2@aklaver.com
Whole thread Raw
In response to Emitting JSON to file using COPY TO  (Davin Shearer <scholarsmate@gmail.com>)
Responses Re: Emitting JSON to file using COPY TO  (Dominique Devienne <ddevienne@gmail.com>)
List pgsql-general
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.

> Any assistance would be appreciated.
> 
> Thanks,
> Davin

-- 
Adrian Klaver
adrian.klaver@aklaver.com




pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Emitting JSON to file using COPY TO
Next
From: "Peter J. Holzer"
Date:
Subject: Re: Can user specification of a column value be required when querying a view ?