pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Johnson, Bruce E - (bjohnson) <bjohnson@arizona.edu>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: [EXT]Re: running \copy through perl dbi ?
Date: Sun, 10 Dec 2023 12:02:52 -0800
Message-ID: <c4126f8b-2ff1-4f89-b085-dede708ac987@aklaver.com> (raw)
In-Reply-To: <CFBA9951-9426-43F9-A9DD-64520562CFD2@email.arizona.edu>
References: <CAEs=6DmZLwYre2AF8Li0HgL8AKFG3NwAzGEonLO0TGPk2fsZdg@mail.gmail.com>
	<20231210184132.a00d55eb898891a6933896d5@wanadoo.fr>
	<CFBA9951-9426-43F9-A9DD-64520562CFD2@email.arizona.edu>

On 12/10/23 10:34, Johnson, Bruce E - (bjohnson) wrote:
> 
>> On Dec 10, 2023, at 10:41 AM, Vincent Veyron <vv.lists@wanadoo.fr 
>> <mailto:vv.lists@wanadoo.fr>> wrote:
>>
>> External Email
>>
>> On Fri, 8 Dec 2023 10:45:28 -0500

>>
>> Duh! I just realized that what I proposed with system() is a command 
>> line approach.
>>
>> As David Johnston mentionned, you can use the SQL COPY command.
> 
> One thing to remember with the Perl DBI is that you can use a string 
> variable in the $dbh->do() command.
> 
> Perl uses 2 different string variable delimiters:
> 
> 1)  ‘ ‘ , which is exactly what you enter $s= ‘\copy * from foo as 
> json’; will send that to the database without the need for escaping 
> anything (unless you need to enter an actual ‘ in the command, in which 
> case method two is better)

The issue is \copy is not a SQl statement, it is a psql(Postgres command 
line client) meta-command. This means it can only be used in psql.

> -- 
> Bruce Johnson
> University of Arizona
> College of Pharmacy
> Information Technology Group
> 
> Institutions do not have opinions, merely customs
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com






view thread (10+ messages)  latest in thread

Message-ID: <c4126f8b-2ff1-4f89-b085-dede708ac987@aklaver.com>
Permalink:  ../c4126f8b-2ff1-4f89-b085-dede708ac987@aklaver.com/
Also on:    postgresql.org/message-id/c4126f8b-2ff1-4f89-b085-dede708ac987@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, bjohnson@arizona.edu
  Subject: Re: [EXT]Re: running \copy through perl dbi ?
  In-Reply-To: <c4126f8b-2ff1-4f89-b085-dede708ac987@aklaver.com>
  References: <CAEs=6DmZLwYre2AF8Li0HgL8AKFG3NwAzGEonLO0TGPk2fsZdg@mail.gmail.com> <20231210184132.a00d55eb898891a6933896d5@wanadoo.fr> <CFBA9951-9426-43F9-A9DD-64520562CFD2@email.arizona.edu> <c4126f8b-2ff1-4f89-b085-dede708ac987@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