Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jm5md-0005Xi-H1 for pgsql-admin@arkaria.postgresql.org; Fri, 19 Jun 2020 01:25:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jm5mb-0008Cv-IP for pgsql-admin@arkaria.postgresql.org; Fri, 19 Jun 2020 01:25:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jm5ma-0008C1-Jr; Fri, 19 Jun 2020 01:25:28 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jm5mX-0005Zb-3E; Fri, 19 Jun 2020 01:25:27 +0000 Received: by mail-wm1-x32a.google.com with SMTP id t194so7564245wmt.4; Thu, 18 Jun 2020 18:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:content-transfer-encoding:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=/hb8RteBwSg0+uPkOwWA6OtV2zX8v5/HuC1i6hEGqo8=; b=QYdVCQVNZsKBGKFKWh9blmOp2c8tuKdWu2enQYQTUAk7z19nkwzIbuNp5MNK6Lyigf IAkJCayNb8kF6inbQgWf7xQKHj7D5v4HORepwXruSMphc76Mmkp4UvHTGps59LOp9u2l n+kGSWPdLdQ7HVmHHLvgtWYjP05AnG8IgtoYSx1IkwxncGpfuSKkczbefdmGFAGk0WuF S4t9Tlynd3B5loKJ/BBFpJMdMwrsFiN6q68O+VlW2PVI3ila9XqmoAsZ9Giec7ewMX17 +dzZp3NoNZfbdNN2uYapa6K9F1sX6U2e9xBtECbx3DQspxqimVsevJirpoCVkUW/VcSW ++OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=/hb8RteBwSg0+uPkOwWA6OtV2zX8v5/HuC1i6hEGqo8=; b=fik7yCgl0s3u6b51rIEzi7QRNGoCAhCU/tVIQjCZDLXJMlr/S/0nR+8JgPrVbA/Q7e 5Sr7+ABZH9mEY5potAEMJYyO4CM0uKBNdmJaaRnIRj6yJfyYYX3xn9XrXqw9bl+UaP/O Ra39vqcu1SiXeEt/BMEt9ot3QM5eUxJIeU6onfZSCjakxdBq8d7jk043BhxvBXy65Ovm 0J57F6lAs7UMbTtbyuFV2qBx9beoTl+sooFZKQ2z5cQnXq0qrYUJ+zQ5q67G2VOZs54u VkIXJ++IJ1VYx2dWIy/7SFrmJlAoZjdVJmr+Vw8VtGgdn496NCTnddQOAImQISk1KgFh JCxw== X-Gm-Message-State: AOAM532p3Qe0qjpvl67IvqAMMRyRPQThQGDMk0m1qjaxk1wUJcJzbxQs ti9L/c8OXNAaRaUmnHFxbyQXKnQyihg= X-Google-Smtp-Source: ABdhPJyLfYqqm5XtPhoNOURV9rrw0htegf+LemW0HXgH4n1mKX55d4sOwtMAI418kN2ppBvnOl2Pig== X-Received: by 2002:a7b:c5c7:: with SMTP id n7mr1043734wmk.77.1592529922584; Thu, 18 Jun 2020 18:25:22 -0700 (PDT) Received: from ?IPv6:2a01:e0a:350:5680:8881:a15a:7972:aeb2? ([2a01:e0a:350:5680:8881:a15a:7972:aeb2]) by smtp.gmail.com with ESMTPSA id x13sm5410168wre.83.2020.06.18.18.25.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 18 Jun 2020 18:25:22 -0700 (PDT) From: cgerard999@gmail.com X-Google-Original-From: Cgerard999@gmail.com Content-Type: multipart/alternative; boundary=Apple-Mail-541EF345-4B4F-4331-A512-E44BC39AA9A5 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (1.0) Subject: Re: create batch script to import into postgres tables Date: Fri, 19 Jun 2020 03:25:21 +0200 Message-Id: References: <37a9ad71-b297-96b3-9c1f-1043e75dec58@aklaver.com> Cc: Pepe TD Vo , Christopher Browne , Pgsql-admin , Pgsql-general In-Reply-To: <37a9ad71-b297-96b3-9c1f-1043e75dec58@aklaver.com> To: Adrian Klaver X-Mailer: iPhone Mail (17F80) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail-541EF345-4B4F-4331-A512-E44BC39AA9A5 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Remove the quotes around echo echo select count(*) from web_20200619; | "C:\Program Files\postgresql\11\bi= n\psql" -d *** -h *** -U *** or, store your query into a text file and use=20 psql -f query.sql Sent from my mobile phone > Le 19 juin 2020 =C3=A0 02:00, Adrian Klaver a =C3= =A9crit : >=20 > =EF=BB=BFOn 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 host= name.amazonaws.com -p 5432 >=20 >=20 > This is getting old. The error is? >> I can run 'psql -u postgres -d PSCIDR -p 5432' (on Linux server, still le= arning 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 i= n both aws and linux. Otherwise manually run using pgAdmin. >> v/r, >> ** >> *Bach-Nga >=20 >=20 > --=20 > Adrian Klaver > adrian.klaver@aklaver.com >=20 >=20 --Apple-Mail-541EF345-4B4F-4331-A512-E44BC39AA9A5 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable

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 =C3=A0 02:00, Adrian Klaver <adrian.klaver@a= klaver.com> a =C3=A9crit :

=EF=BB=BFOn 6/18/20 4:37 PM, Pepe TD Vo wr= ote:
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 PSm= asteruser -d PSCIDR -h hostname.amazonaws.com -p 5432


This is getting old. The error is?<= /span>
I can run 'psql -u postgres -d PSC= IDR -p 5432' (on Linux server, still learning how to run it from psql shell i= n Window) fine from psql prompt.  Just still wonder how to connect dire= ctly to the instance PSCIDR from scripting in both aws and linux.  Othe= rwise manually run using pgAdmin.
v/r,
**<= /span>
*Bach-Nga
<= /blockquote>

--
Adri= an Klaver
adrian.klaver@aklaver.com
<= br>
= --Apple-Mail-541EF345-4B4F-4331-A512-E44BC39AA9A5--