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 1hDtHY-0005ec-Rl for pgsql-admin@arkaria.postgresql.org; Tue, 09 Apr 2019 16:07:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDtHX-0003tq-IH for pgsql-admin@arkaria.postgresql.org; Tue, 09 Apr 2019 16:07:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDtHX-0003tj-66 for pgsql-admin@lists.postgresql.org; Tue, 09 Apr 2019 16:07:31 +0000 Received: from 87-253-140-15.colo.transip.net ([87.253.140.15] helo=mail.osdev.nl) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDtHU-0007Te-Ch for pgsql-admin@lists.postgresql.org; Tue, 09 Apr 2019 16:07:29 +0000 X-Clacks-Overhead: "GNU Terry Pratchett" Received: from skullcandy.osdev.nl (static.kpn.net [93.154.102.132] (may be forged)) (authenticated bits=0) by mail.osdev.nl (8.14.4/8.14.4) with ESMTP id x39G7JCm020329; Tue, 9 Apr 2019 18:07:19 +0200 Date: Tue, 9 Apr 2019 18:07:19 +0200 From: "Peter M. Groen" To: Scott Whitney Cc: "pgsql-admin@lists.postgresql.org" , Ron Subject: Re: How to insert from linux to postgreSQL Message-ID: <20190409180719.1902610a@skullcandy.osdev.nl> In-Reply-To: References: <4FB9BF8B-D26C-40FB-9A9C-DEB4FB016292@illinois.edu> Organization: Open Systems Development X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (mail.osdev.nl [87.253.140.15]); Tue, 09 Apr 2019 18:07:20 +0200 (CEST) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,UNPARSEABLE_RELAY, URIBL_BLOCKED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on bohr.osdev.nl List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Or just use PERL as it was designed to (pre)process large amounts of texts... psql support is pretty great.... -- Open Systems Development B.V. Peter M. Groen Rooseveltstraat 18P 2321 BM Leiden Telef : Mobile : +31 6 811 0 3537 Email : pgroen@osdev.nl On Mon, 8 Apr 2019 19:20:03 +0000, Scott Whitney wrote : >Is the log file "ready" for INSERT, line by line? If not, you need to >preprocess it. The 2 solutions I would use are psycopg for Python or >sed + INSERT depending. ________________________________ From: Ron > Sent: Monday, April 8, 2019 2:18:18 PM >To: pgsql-admin@lists.postgresql.org >Subject: Re: How to insert from linux to postgreSQL > >On 4/8/19 2:03 PM, Campbell, Lance 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. > >Presumably some manipulations need to be performed so that you can't >just do COPY FROM STDIN? > >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? > >I think the problem is that you need an open connection to use >prepared statements, and you can't do that in bash. What about using >Python? (After all, that's a scripting language, too.) > > >-- >Angular momentum makes the world go 'round. > > > >[http://journyx.com/emailImages/ScottWhitney.png] > >[http://journyx.com/emailImages/linkedin.png] >[http://journyx.com/emailImages/twitter.png] > > [http://journyx.com/emailImages/bluebar.jpg] > >Scott Whitney >Director of IT > >[http://journyx.com/emailImages/journyx.jpg] > >scott@journyx.com | +1 (800) 755-9878 > >7600 Burnet Road, Ste. 300 >Austin, TX 78757 > >Visit us at www.journyx.com > > > >To unsubscribe from Journyx promotional emails, click here > or visit >http://journyx.com/communication-preferences.