pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Mark Mikulec <mark@mikutech.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Can't quote_literal with COPY FROM PROGRAM
Date: Mon, 31 Dec 2018 13:00:52 -0800
Message-ID: <d18c27c2-72d4-15da-973a-c0fa90ff9714@aklaver.com> (raw)
In-Reply-To: <CA+aX0efS0juJfAfxZO5oZU9EeWgoDCG0RCoiHyNv7orYbJ_uOg@mail.gmail.com>
References: <CA+aX0efk8+9WAHGsC8vtiuxPsZPik=aUUHrPXyp5L7Kq9HNLHA@mail.gmail.com>
	<daa5451d-fad6-44cb-c906-5e0e3aec7550@aklaver.com>
	<CA+aX0efS0juJfAfxZO5oZU9EeWgoDCG0RCoiHyNv7orYbJ_uOg@mail.gmail.com>

On 12/31/18 12:58 PM, Mark Mikulec wrote:
> I changed it to be just the single float value I needed to extract out 
> of the JSON object, but originally it was a text column that held the 
> entire JSON object.

Might want to look at:

https://www.postgresql.org/docs/10/datatype-json.html

Might handle the escaping better.

> ᐧ
> 
> On Mon, Dec 31, 2018 at 3:52 PM Adrian Klaver <adrian.klaver@aklaver.com 
> <mailto:adrian.klaver@aklaver.com>> wrote:
> 
>     On 12/31/18 9:36 AM, Mark Mikulec wrote:
>      > Hi,
>      >
>      > This command, which generates a JSON object as output, has some
>     escaped
>      > data with backslashes: (see line 91 here:
>     https://pastebin.com/D4it8ybS)
>      >
>      > C:\\Portable\\curl\\curl.exe -k
>      >
>     "https://maps.googleapis.com/maps/api/directions/json?etcVariablesDeleted"';
>      >
>      > I use the COPY command to pull it into a temp table like so:
>      >
>      > COPY temp_maps_api from program 'C:\\Portable\\curl\\curl.exe -k
>      >
>     "https://maps.googleapis.com/maps/api/directions/json?etcVariablesDeleted"';;
> 
>     So temp_maps_api has a single JSON field?
> 
>      >
>      > However copy eats those backslashes. I need to use
>     quote_literal() but
>      > that's a syntax error. For some reason the COPY command doesn't
>     allow
>      > for ESCAPE to work with programs, only CSV.
>      >
>      > I tried using WITH BINARY but I get the error message: "COPY file
>      > signature not recognized"
>      >
>      > Does anyone know how to make COPY FROM PROGRAM take the output
>     literally?
>      >
>      > Thanks,
>      >    Mark
>      > ᐧ
> 
> 
>     -- 
>     Adrian Klaver
>     adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (8+ messages)  latest in thread

Message-ID: <d18c27c2-72d4-15da-973a-c0fa90ff9714@aklaver.com>
Permalink:  ../d18c27c2-72d4-15da-973a-c0fa90ff9714@aklaver.com/
Also on:    postgresql.org/message-id/d18c27c2-72d4-15da-973a-c0fa90ff9714@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, mark@mikutech.com
  Subject: Re: Can't quote_literal with COPY FROM PROGRAM
  In-Reply-To: <d18c27c2-72d4-15da-973a-c0fa90ff9714@aklaver.com>
  References: <CA+aX0efk8+9WAHGsC8vtiuxPsZPik=aUUHrPXyp5L7Kq9HNLHA@mail.gmail.com> <daa5451d-fad6-44cb-c906-5e0e3aec7550@aklaver.com> <CA+aX0efS0juJfAfxZO5oZU9EeWgoDCG0RCoiHyNv7orYbJ_uOg@mail.gmail.com> <d18c27c2-72d4-15da-973a-c0fa90ff9714@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox