Re: create batch script to import into postgres tables

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pepevo <pepevo(at)yahoo(dot)com>, cgerard999(at)gmail(dot)com, Christopher Browne <cbbrowne(at)gmail(dot)com>, Pgsql-admin <pgsql-admin(at)postgresql(dot)org>, Pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: create batch script to import into postgres tables
Date: 2020-06-19 14:57:03
Message-ID: CAKFQuwadjyw5tG1soX+jcYWsN_MyRbQkCz_J43XpkoB_=T0_Xg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

On Fri, Jun 19, 2020 at 7:33 AM Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
wrote:

> On 6/19/20 7:17 AM, pepevo wrote:
> > I understand your post about "password does not take an argument, it is
> > meant to be used as is. The purpose is to force a password prompt." When
> > I used -W and --password=. That's what I said I will try pgpassfile.
> > Thought it like mysq/oracle can indicate out without creating password
> > file.
>
> If you want to expose your password in the script file then:
>
> https://www.postgresql.org/docs/12/app-psql.html
>
> Usage
> Connecting to a Database
>
> "An alternative way to specify connection parameters is in a conninfo
> string or a URI, which is used instead of a database name. This
> mechanism give you very wide control over the connection. For example:
>
> $ psql "service=myservice sslmode=require"
> $ psql postgresql://dbmaster:5433/mydb?sslmode=require
>
> This way you can also use LDAP for connection parameter lookup as
> described in Section 33.17. See Section 33.1.2 for more information on
> all the available connection options."
>
> So:
>
> psql
> postgresql://PSmasteruser:mypassword(at)hostname(dot)amazonaws(dot)com:5432/PSCIDR
>
> or
>
> psql 'dbname=PSCIDR user=PSmasteruser host=hostname.amazonaws.com port=
> 5432 password=mypassword '
>
>
Ok, so not "no way", but it's still a bad idea given the availability of
other better options. Namely PGPASSWORD, .pgpass, or, less
desirably.pg_service.conf

The URI format that includes a password should be reserved for client
libraries and avoided when using psql (just the password part really though
I much prefer the service file option myself).

David J.

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Adrian Klaver 2020-06-19 14:57:31 Re: create batch script to import into postgres tables
Previous Message David G. Johnston 2020-06-19 14:52:54 Re: create batch script to import into postgres tables

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2020-06-19 14:57:31 Re: create batch script to import into postgres tables
Previous Message David G. Johnston 2020-06-19 14:52:54 Re: create batch script to import into postgres tables