Re: create batch script to import into postgres tables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jun 19, 2020 at 7:33 AM Adrian Klaver <adrian.klaver@xxxxxxxxxxx> 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@xxxxxxxxxxxxxxxxxxxxxx: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.


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux