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 1hDa1k-000413-Jw for pgsql-admin@arkaria.postgresql.org; Mon, 08 Apr 2019 19:33:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDa1i-0006jA-79 for pgsql-admin@arkaria.postgresql.org; Mon, 08 Apr 2019 19:33:54 +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 1hDa1h-0006j3-Tp for pgsql-admin@lists.postgresql.org; Mon, 08 Apr 2019 19:33:53 +0000 Received: from impout004aa.msg.chrl.nc.charter.net ([47.43.20.28] helo=impout004.msg.chrl.nc.charter.net) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDa1a-0000cx-J3 for pgsql-admin@postgresql.org; Mon, 08 Apr 2019 19:33:53 +0000 Received: from cerberus.crazybean.net ([24.151.10.150]) by cmsmtp with ESMTP id Da1XhxtkHmrIrDa1Xhka12; Mon, 08 Apr 2019 19:33:44 +0000 Authentication-Results: crazybean.net; none X-Authority-Analysis: v=2.3 cv=eO2nc0h1 c=1 sm=1 tr=0 a=D2HTw/M6/8MmcHighGO7rg==:117 a=D2HTw/M6/8MmcHighGO7rg==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=xqWC_Br6kY4A:10 a=oexKYjalfGEA:10 a=0Wkxbn5hAAAA:8 a=pM9yUfARAAAA:8 a=Ssw8bEc9GR-scjgZ5IIA:9 a=CjuIK1q_8ugA:10 a=5anqXUQTfUwA:10 a=b_bQtQT6C6QA:10 a=PMUsFDT6ZkYcsbU8:21 a=_W_S_7VecoQA:10 a=gOtJ9kO4XfHesgqOi9eT:22 a=YH-7kEGJnRg4CV3apUU-:22 Received: from [IPv6:2001:470:e117:4:9c7d:ddd7:d986:e946] (2001:470:e117:4:9c7d:ddd7:d986:e946 [IPv6:2001:470:e117:4:9c7d:ddd7:d986:e946]) by cerberus.crazybean.net (OpenSMTPD) with ESMTPSA id 39137afa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 8 Apr 2019 15:33:43 -0400 (EDT) From: Rui DeSousa Message-Id: <80D01A64-24BA-420D-B963-2F8BCDA8AA7D@crazybean.net> Content-Type: multipart/alternative; boundary="Apple-Mail=_8658EC32-6057-4035-BEE7-0A868994CF15" Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: Re: How to insert from linux to postgreSQL Date: Mon, 8 Apr 2019 15:33:42 -0400 In-Reply-To: <4FB9BF8B-D26C-40FB-9A9C-DEB4FB016292@illinois.edu> Cc: "pgsql-admin@postgresql.org" To: "Campbell, Lance" References: <4FB9BF8B-D26C-40FB-9A9C-DEB4FB016292@illinois.edu> X-Mailer: Apple Mail (2.3445.102.3) X-CMAE-Envelope: MS4wfD/q6WeKnR7gAfEmW3epIz3ydswxqb6GHBop+MLAM173yZqL4jDAQ4A4VIBPUsm4vjMckZ5n5b91wzS/aVI578W/WzewllJJm+eFxmQXLBz5M78/pBFD plwS7jojsCkBYPuDUVyiim96P4iGcmvPbD6X7ZMV+2SUzQWRuKeAhk/s5egldrf+OMKgVbBMjNbkzcRYAKSy1oN7imvuK761QvlFRQ7mfkO5UBqBspqY1GMA List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_8658EC32-6057-4035-BEE7-0A868994CF15 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii I would use psql \copy command within a shell script or just not use it. = =20 Personally, I would choose Perl or GoLang if it requires parsing the = data before inserting. =20 Perl: https://www.perl.com/pub/1999/10/DBI.html/ = Go: https://golang.org/pkg/database/sql/#DB.Prepare = > On Apr 8, 2019, at 3:03 PM, Campbell, Lance = wrote: >=20 > PostgreSQL 10.x > =20 > Use case: > I want to read a log file on my linux server and write each line out = to a row in a postgreSQL table. When I do inserts however I want to = make sure I am using prepared statements to avoid SQL injections. I = know how to do this is Java but I have not found an example using a = linux bash scripts.=20 > =20 > Does anyone have an example they could point me to? > =20 > Thanks, > =20 > Lance --Apple-Mail=_8658EC32-6057-4035-BEE7-0A868994CF15 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii I = would use psql \copy command within a shell script or just not use it. =  

Personally, I = would choose Perl or GoLang if it requires parsing the data before = inserting.  



On Apr = 8, 2019, at 3:03 PM, Campbell, Lance <lance@illinois.edu> = wrote:

PostgreSQL 10.x
 
Use case:
I want to read a log file on my = linux server and write each line out to a row in a postgreSQL = table.  When I do inserts however I want to make sure I am using = prepared statements to avoid SQL injections.  I know how to do this = is Java but I have not found an example using a linux bash = scripts. 
 
Does anyone have = an example they could point me to?
 
Thanks,
 
Lance

= --Apple-Mail=_8658EC32-6057-4035-BEE7-0A868994CF15--