Re: create batch script to import into postgres tables

From: Pepe TD Vo <pepevo(at)yahoo(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, <cgerard999(at)gmail(dot)com>
Cc: 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 11:12:30
Message-ID: 939136830.464657.1592565150445@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

thank you,   I tried that too, remove the quote around the echo and it prompt for password, as I mentioned no matter I put -P mypassword no matter what I spell out password=mypassword still argument error
>>echo select count(*) from tableA; | "C:\Program Files\PostgreSQL\11\bin\psql" -U PSmasteruser -d PSCIDR -h hostname.amazonaws.com -p 5432  

>> echo select count(*) from tableA; | "C:\Program Files\PostgreSQL\11\bin\psql" -U PSmasteruser -d PSCIDR -h hostname.amazonaws.com -p 5432 password=mypassword
all usernames are same password.
thank you so much for all input.
v/r,
Bach-Nga

No one in this world is pure and perfect.  If you avoid people for their mistakes you will be alone. So judge less, love, and forgive more.To call him a dog hardly seems to do him justice though in as much as he had four legs, a tail, and barked, I admit he was, to all outward appearances. But to those who knew him well, he was a perfect gentleman (Hermione Gingold)
**Live simply **Love generously **Care deeply **Speak kindly.*** Genuinely rich *** Faithful talent *** Sharing success

On Thursday, June 18, 2020, 09:25:41 PM EDT, <cgerard999(at)gmail(dot)com> wrote:


Remove the quotes around echo

echo select count(*) from web_20200619; | "C:\Program Files\postgresql\11\bin\psql" -d *** -h *** -U ***

or, store your query into a text file and use 

psql -f query.sql

Sent from my mobile phone

Le 19 juin 2020 à 02:00, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> a écrit :

On 6/18/20 4:37 PM, Pepe TD Vo wrote:

thank you for the link.  I did try it and it's still error

echo 'SELECT count(*) FROM tableA;' |

C:\Program Files\PostgreSQL\11\bin\psql -U PSmasteruser -d PSCIDR -h hostname.amazonaws.com -p 5432

This is getting old. The error is?

I can run 'psql -u postgres -d PSCIDR -p 5432' (on Linux server, still learning how to run it from psql shell in Window) fine from psql prompt.  Just still wonder how to connect directly to the instance PSCIDR from scripting in both aws and linux.  Otherwise manually run using pgAdmin.

v/r,

**

*Bach-Nga

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Hotmail 2020-06-19 12:59:03 Re: Any optimizations using oracle_fdw with oracle tables that have clob columns?
Previous Message ZongtianHou 2020-06-19 07:17:18 Re: how to insert row with specific oid

Browse pgsql-general by date

  From Date Subject
Next Message Amul Sul 2020-06-19 12:14:27 Re: HASH partitioning not working properly
Previous Message Srinivasa T N 2020-06-19 10:20:12 Re: HASH partitioning not working properly