Re: create batch script to import into postgres tables

2020-06-18 Thread cgerard999
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  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.kla...@aklaver.com
> 
> 


Re: create batch script to import into postgres tables

2020-06-19 Thread cgerard999
There is an alternate solution, which is to launch pgadmin GUI, connect to the 
database, tick « save password »  
Then psql won’t prompt fir password any more. 
Pay however attention to the security concern. 

Sent from my mobile phone

> Le 19 juin 2020 à 17:07, Pepe TD Vo  a écrit :
> 
> 
> appreciate for clarification, all inputs and teaching me more in PostgreSQL
> 
> have a good weekend and happy father's day to all who is Father.
> 
> 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 Friday, June 19, 2020, 10:57:59 AM EDT, Adrian Klaver 
>  wrote:
> 
> 
> On 6/19/20 7:52 AM, David G. Johnston wrote:
> > On Fri, Jun 19, 2020 at 6:58 AM Adrian Klaver  > > wrote:
> > 
> >On 6/19/20 6:53 AM, Pepe TD Vo wrote:
> >  > Thank you sir and I am sorry for the typo not having "--" on
> >password.
> >  > I did spelling out with --password=mypassword
> > 
> >Please go back and read my post again.
> > 
> > 
> > To be clear, there is no way to supply a password as a command line 
> > argument.  It is fundamentally a bad idea and we don't even make it an 
> > option.
> 
> Actually that is not entirely true, see my follow up post.
> 
> > 
> > You need to decide on one of the actual ways of supplying a password, or 
> > choose an alternative authentication method like peer.
> > 
> > David J.
> 
> > 
> 
> 
> -- 
> Adrian Klaver
> adrian.kla...@aklaver.com
> 
>