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 1hDZmo-00037q-4a for pgsql-admin@arkaria.postgresql.org; Mon, 08 Apr 2019 19:18:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDZmm-0000nu-Iy for pgsql-admin@arkaria.postgresql.org; Mon, 08 Apr 2019 19:18:28 +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 1hDZmm-0000iv-3Z for pgsql-admin@lists.postgresql.org; Mon, 08 Apr 2019 19:18:28 +0000 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hDZmf-00068a-DL for pgsql-admin@lists.postgresql.org; Mon, 08 Apr 2019 19:18:26 +0000 Received: by mail-oi1-x244.google.com with SMTP id a6so11452702oie.5 for ; Mon, 08 Apr 2019 12:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=4sqJwVie/gUq/miLcnzH4iLnpsPzvY4I0h7r2Wo5cF0=; b=FChbDKviiBUrubLHH+4rriZZb1hUdPxvPCxzHrLCGU/SQnPPiGOV9SX/bUxZIEYNH/ yt/f/phxz6AEGc777Eb6H6+de/YdtcLGTmjqhEcSp7oZDtk1Sp00rfIur3I6+cBdrXLm 0sq1vSFYVI1UgxIC9rJObyRkcea5k0X7lrtNi5/X0ZcxcobEgQ5gose8kyBtrEfJua6L CsKbESBNKkccwN32U43QIEk+TnnreTaVg1LTy8aOWHx1FBqfmc6ke6VgBtSnLRq1dEj2 FMVCp5q1B6+l5Nrdq0plWiMYI9hfGwGO0Mk0zL/GYlX0XyyzCVflPOQd5+RUsxn5tgDR 3/LQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=4sqJwVie/gUq/miLcnzH4iLnpsPzvY4I0h7r2Wo5cF0=; b=B4HWyaz/fufAUk6sGXaeW1zkFp4MhC03simlj3eTLF7aPKzwPm7YKf7DOMneR+x6U4 UbbRwC8Y5oTmhj7vj7pLiVapNFWvd+BZoD+CiOaUfhFnJczm7yv+NXTTLVXRanevct72 0huRnURa1OO38VIi7bZ2l06+D8vf4ZBseiyVNrFsjnJI24df99RG29jeMgP5l3ub7Oui Ppt4JQqfQj4WsHlYD43MYDtiY5t6MUi9EvYsj2nuvns31d6E5tZ0hTiX49i+4nnQAfxH n9uqs5wUh/93BTYlm9+m/DjzEiPEVqrALpTGs1zGVbJDdwkmBAG3IVhPGP+gQGalkkK3 EobQ== X-Gm-Message-State: APjAAAXRx0dsqdq/DbtJGyD7igTL44vxws6sHxUI9sAPf2z594guqXnZ 2lNKERqvScDsYG7E3sc0Yqi3e33oAwI= X-Google-Smtp-Source: APXvYqxx/DEcEpI0rJ7lsYQe4ucM9WtMS/fi95MLIX4A+YYWPwP2JhFeBKW/i2hRvaGuwE203tz8tA== X-Received: by 2002:aca:4a8e:: with SMTP id x136mr17045342oia.136.1554751100304; Mon, 08 Apr 2019 12:18:20 -0700 (PDT) Received: from [192.168.1.10] (ip70-171-116-89.no.no.cox.net. [70.171.116.89]) by smtp.googlemail.com with ESMTPSA id v24sm11356815oic.32.2019.04.08.12.18.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Apr 2019 12:18:19 -0700 (PDT) Subject: Re: How to insert from linux to postgreSQL To: pgsql-admin@lists.postgresql.org References: <4FB9BF8B-D26C-40FB-9A9C-DEB4FB016292@illinois.edu> From: Ron Message-ID: Date: Mon, 8 Apr 2019 14:18:18 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <4FB9BF8B-D26C-40FB-9A9C-DEB4FB016292@illinois.edu> Content-Type: multipart/alternative; boundary="------------039648C0067204877CA8C40B" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------039648C0067204877CA8C40B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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. --------------039648C0067204877CA8C40B Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit 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.
--------------039648C0067204877CA8C40B--