Re: create batch script to import into postgres tables

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: create batch script to import into postgres tables
Дата
Msg-id CAKFQuwadjyw5tG1soX+jcYWsN_MyRbQkCz_J43XpkoB_=T0_Xg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: create batch script to import into postgres tables  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-admin
On Fri, Jun 19, 2020 at 7:33 AM Adrian Klaver <adrian.klaver@aklaver.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@hostname.amazonaws.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.

В списке pgsql-admin по дате отправления:

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: create batch script to import into postgres tables
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: create batch script to import into postgres tables