psql command at the prompt. (Postgresql Bank)

2

Good morning,

I'm trying to make a script with .bat extension to do automatic update in the bank, except that in order to do this I need to know how to enter the password of my bank through command.

I'm doing the following to access my bank through windows prompt. psql -U bank user -w bank password

however I get the following message fe_sendauth: no passoword supplied

NOTE: when typing (psql -U bank user) it asks for the password but, that's just what I want it to not appear. I want to enter the password by command.

    
asked by anonymous 16.02.2017 / 17:13

3 answers

2

Create a password file containing a line like

*:*:teste:postgres:senha

The file must be %APPDATA%\postgresql\pgpass.conf

To find out what directory %APPDATA% type at the prompt:

echo %APPDATA%
    
16.02.2017 / 18:21
2

I've always had the question of the postgres password in my examples too ...

Then in my .BAT I created a line with the following command:

SET PGPASSWORD=postgres

(my example password is postgres , did not need quotes or anything ...)

After that, I added new line in .bat to execute the command I needed as follows, and did not question me password:

echo on
C:\"Program Files"\PostgreSQL.5\bin\psql.exe -h LOCALHOST -U postgres -d nomedabasedados -c "Update nometabela  set dt_atualizacao = LOCALTIMESTAMP where cod_oper = %OPERADORA% " 
    
16.01.2018 / 19:22
0

Add -w, as follows:

psql -d mydb -U myuser -W
    
16.02.2017 / 17:17