Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rCQ29-00Fq1X-Gq for pgsql-general@arkaria.postgresql.org; Sun, 10 Dec 2023 20:04:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rCQ17-008W1j-Uc for pgsql-general@arkaria.postgresql.org; Sun, 10 Dec 2023 20:03:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rCQ16-008W1a-4I for pgsql-general@lists.postgresql.org; Sun, 10 Dec 2023 20:03:09 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rCQ0x-00BGY5-Rf for pgsql-general@lists.postgresql.org; Sun, 10 Dec 2023 20:03:07 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id C78943200A06; Sun, 10 Dec 2023 15:02:54 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 10 Dec 2023 15:02:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm3; t= 1702238574; x=1702324974; bh=cu3thHQOEfEu2UP9DNSP9lKwbN8/3AtUNsT ojZXOYP4=; b=YMSVagSSmeFem5PV5h3JFXCA/NmQnwIpfbUNl+q+L8u1nzoweE2 z8xrPUCNuxPLVPv8VeXHSIb3VncerWpixbb2XGqr/ZDGSl8+2qYAhswK3c3Oml8/ NLNDLMKAxAYf0IJ0voj/RwVidS2Fc4oFIYvfAf8dOLpG1ueYhBKM9xGfBOiMy1wK DeOQ6Q+fApxF8a7JvFA7Iug2VlAKooiqd9njCyi/g6nkm69iGr8x7Y6vuRNnHVhX ATRh00reZTEjONTjtd7+Wqp2oC2+I4b0RmIUNrbb231wzF2u9PsXDj+Gcl5Uhint hGCOsO4ii995VnvmCX1Ad5gT79OiIg3BkmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1702238574; x= 1702324974; bh=cu3thHQOEfEu2UP9DNSP9lKwbN8/3AtUNsTojZXOYP4=; b=P nEtjaXWyt6Z/cCsCfUMkhOZCFN3oG9sybPBM/4cTvmsaw41FmUpntOSKwdQSmxyy wj5SV0xuGqmNyWpHzG8Bj8c/8c977QclahoSvHDB/zVd+FzBLuXndRk0kXyei9JE FZkQ729tfkGOk6CrKxIuZBJ3eYekeMYjjdII7sNf7QfqphTk/DZNl1JmMX9qZ6+h pYX3uKBCzdeSWmTlYDO3F5CshDEn2LHxIVImsn145RUxYNmbuhzUOuhMybsl9vkD rTtyU/zAnkDGsdDTsLr9XFyxp5RZGAvkYeR0Ep1uzmAplYnonqbVD9L5UbNuTVue kDdpZOuz1Mivj0aXbiA0g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeltddgudefgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfekuedtffejveegffeg jeevtdehgfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 10 Dec 2023 15:02:53 -0500 (EST) Message-ID: Date: Sun, 10 Dec 2023 12:02:52 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [EXT]Re: running \copy through perl dbi ? To: "Johnson, Bruce E - (bjohnson)" , "pgsql-general@lists.postgresql.org" References: <20231210184132.a00d55eb898891a6933896d5@wanadoo.fr> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/10/23 10:34, Johnson, Bruce E - (bjohnson) wrote: > >> On Dec 10, 2023, at 10:41 AM, Vincent Veyron > > 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