Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ge2mP-0002z9-JI for pgsql-general@arkaria.postgresql.org; Mon, 31 Dec 2018 18:59:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ge2mM-0006yu-VS for pgsql-general@arkaria.postgresql.org; Mon, 31 Dec 2018 18:59:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ge2mM-0006yN-LB for pgsql-general@lists.postgresql.org; Mon, 31 Dec 2018 18:59:10 +0000 Received: from mail-it1-x129.google.com ([2607:f8b0:4864:20::129]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ge2mJ-0007hs-Cq for pgsql-general@postgresql.org; Mon, 31 Dec 2018 18:59:09 +0000 Received: by mail-it1-x129.google.com with SMTP id g76so36556795itg.2 for ; Mon, 31 Dec 2018 10:59:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=KBdkH4tJeOZF+r2oKb+lkBle/Owfj+nmMkXU8z0zc8o=; b=vYtiHeVsZdc54UUPtFNjuf3CvawDMOzvEeB9kkxy502giwosZAifR9G7UmezcoAjU8 TbKrIMOe4RDmn7pFnO6CixQ6ijcvD9zzQ/cw9sxK1rpaJFSXgPKARUAVwiyS8Ab/2/Le nJy5EbrOCTfLxTN70YXYz9dcPdMPaTrnRj9XNeFd7rwn9+CkmEZhs2xHOeJMXfTzlYhZ 4bYL71k1eoaGBx3K8JS7hbqKsIXp6l5dwyBC3HFJt0n00kowWpnKakdrVOrOvlWYwRvT YXsN7xq0xex3cIAIKuFCoirfz3xX7DTzUu2IQPNpSqTyq8F+/zvZ8xDOF5p7HwVumt69 YF4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=KBdkH4tJeOZF+r2oKb+lkBle/Owfj+nmMkXU8z0zc8o=; b=hIOolo8wxdy16PeMacXVzVAdxclL3a+AnOzZ3pc0Z1jePyY2KEshzIPtPyMnRFW8XG wqJP+HZ2AtfVz2zPXDC3UCKfR0APE1WnlrYJTiws/8mst6FnfbCl41njLPe+xJOl7vnf 0LP5r+1UcrmcrHML+rdcheghajcy4YdJshBtMICETPkc3lbB3tTqwtwUQjFxM6X/Ivnr W++PBeVQu434uKffVwp8TV/YPLh1QZElLIGIXu4XeqVQkYiIyWUNzuEkHzBXgpTc+PEA cW118ne59vrEnEDKxPLfMRZ4y4gaBK9ahMabJLw0EzXXF8rbSvIWxWe9tDjLTEjwyg+f JFaw== X-Gm-Message-State: AA+aEWY6JXqbv1LGi8CD3wFmGOlPg2ThG2mY6S+cST0AOLYkJu1cimKr NpWGI32ebfUY/+G9Gvpmka4= X-Google-Smtp-Source: AFSGD/WynJNCOa9d82x0KfIgMQ9D89E4/C5sv0x+lhwgtfjsBrfYXyAXYhDvdGkSFgecjWriTvDWLA== X-Received: by 2002:a24:57c5:: with SMTP id u188mr26789825ita.54.1546282745401; Mon, 31 Dec 2018 10:59:05 -0800 (PST) Received: from ?IPv6:2601:681:5500:1e3c:e01f:e4a8:6c6a:3581? ([2601:681:5500:1e3c:e01f:e4a8:6c6a:3581]) by smtp.gmail.com with ESMTPSA id t6sm23293813ioc.87.2018.12.31.10.59.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Dec 2018 10:59:04 -0800 (PST) Content-Type: multipart/alternative; boundary=Apple-Mail-6B58AD30-D266-4AEA-BD69-0CF8147A2CA8 Mime-Version: 1.0 (1.0) Subject: Re: Can't quote_literal with COPY FROM PROGRAM From: Rob Sargent X-Mailer: iPhone Mail (16B92) In-Reply-To: Date: Mon, 31 Dec 2018 11:59:03 -0700 Cc: pgsql-general@postgresql.org Content-Transfer-Encoding: 7bit Message-Id: References: To: Mark Mikulec List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-6B58AD30-D266-4AEA-BD69-0CF8147A2CA8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On Dec 31, 2018, at 10:36 AM, Mark Mikulec wrote: >=20 > Hi, >=20 > This command, which generates a JSON object as output, has some escaped da= ta with backslashes: (see line 91 here: https://pastebin.com/D4it8ybS) >=20 > C:\\Portable\\curl\\curl.exe -k "https://maps.googleapis.com/maps/api/dire= ctions/json?etcVariablesDeleted"' =20 >=20 > I use the COPY command to pull it into a temp table like so: >=20 > COPY temp_maps_api from program 'C:\\Portable\\curl\\curl.exe -k "https://= maps.googleapis.com/maps/api/directions/json?etcVariablesDeleted"'; >=20 > However copy eats those backslashes. I need to use quote_literal() but tha= t's a syntax error. For some reason the COPY command doesn't allow for ESCAP= E to work with programs, only CSV. >=20 > I tried using WITH BINARY but I get the error message: "COPY file signatur= e not recognized" >=20 > Does anyone know how to make COPY FROM PROGRAM take the output literally? >=20 > Thanks, > Mark > =E1=90=A7 Can you pipe the curl output through sed s,\\,\\\\,g=20 --Apple-Mail-6B58AD30-D266-4AEA-BD69-0CF8147A2CA8 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

On Dec 31, 2018, at 10:36 AM, Mark Mikulec <mark@mikutech.com> wrote:

Hi,

This command, which g= enerates a JSON object as output, has some escaped data with backslashes: (s= ee line 91 here: https://past= ebin.com/D4it8ybS)


I use the COP= Y 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?etcVariablesDele= ted"';

However copy eats those backslashes. I ne= ed to use quote_literal() but that's a syntax error. For some reason the COP= Y command doesn't allow for ESCAPE to work with programs, only CSV.

I tried using WITH BINARY but I get the error message: "COP= Y file signature not recognized"

Does anyone know h= ow to make COPY FROM PROGRAM take the output literally?

=
Thanks,
  Mark
<= /div>
3D""=E1=90=A7
Can you pipe the curl output through sed s,\\,\\\\,g = ;

= --Apple-Mail-6B58AD30-D266-4AEA-BD69-0CF8147A2CA8--