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 1jlDjH-0001sm-FK for pgsql-admin@arkaria.postgresql.org; Tue, 16 Jun 2020 15:42:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlDjG-0004NE-Ee for pgsql-admin@arkaria.postgresql.org; Tue, 16 Jun 2020 15:42:26 +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 1jlDjG-0004N7-2n for pgsql-admin@lists.postgresql.org; Tue, 16 Jun 2020 15:42:26 +0000 Received: from sonic315-13.consmr.mail.bf2.yahoo.com ([74.6.134.123]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jlDjD-0007sx-Gq for pgsql-admin@postgresql.org; Tue, 16 Jun 2020 15:42:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1592322142; bh=L/vkY2Sj1jmJFCIADcYBBTx1gFq8JM8rkUcOrRAt1uA=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:From:Subject; b=HO3WHSc0EI716sICxMIVFFJNJTo6IXUWa/5IMa4F5H4Pu8yEVcBErDS3ZzwJoqziUBKWsnon4YXCvX9Tuv4I+ylCbC6zDETPvvDtdTcTCoOiQICXnvlyFgrtB4pmLgptTtOPQYrWxyB8LyKiJpVPzpoZlD49OP7jZYTTXLgN/kJAQQmKMFMPhmTm9IHMoXNvD76MRFdzfO9N1ewwAC2bg+fBoVe1LzHlyfFymbHQWjZbsGC6IQPaFGKQkTcJt+nukVIeeIMTVCMo0Ehdt9I+ffvJjrejB54VznRbtN72xKhP+qyi8fEIsoRrlZ9bacWuZCBQpDqtLrmg9VeY9PB4zw== X-YMail-OSG: FyY4LsUVM1kCew1TwSRbPmKLmmkxlHtBaO0QCiWbi1hZOTgZ1IPepTqxLkQOrwK TJmcoTgClYrsyqz2P9fEGZhT9ULKhOSKa3nif7KskiUkv2lOugvKSIVHGBbsHRTFb.LibZ4.C4BR yMG5FPy3Ak808a12dtizu_19iYGStFcbK16kncPc36bJYs5TmKoM2Ve43aXOTot1SMl4Q_.VQGHd iorgenPrtQaR7cU10DFNBzgGCHffY_0GhhqxxOjJm2xPVWLzXycn27XP6NGj26_9NZH.ojeqIzdb EED9nb.isLhueEcHAu0ZAmILscNBkFkay9h3RBbezC82mOYVY3Z3cUpQjHnf5yVNx4n.sOd9Dvjj tWbgtseqXfgRqUFXjjiwsQEP_zzBwaSZKtwJOKQxGXeyItFTIyIb7iitjPXuTOjGytRIhTdH_dFL PWzVuS7h8_9P4LQ9pHX9en1jw8JJ7YPX5CicQKsMGtImkyYjNKKwA8QVUe3h9pvw42Nt0.BFcJwB 9_NUv8NLR_5uk81NeSNmpVkzAtbHbV0m_.889rVzI6KfiJH28DesAb7XMjwQpCUj7o.zTQjKSXuk frnJaNZl1DH2m94ZzORxvVmQBRCC1bDHBdtPED.LWhSx9Bsm4vC4JMh0FmJwoVn2JmRCex3jWmoZ nRPh92ESx21QMytu40pcIUNm0q1Gq_9gtY4cu6xJBxJs.mynOR1viYAO1M1SGh5sKS4ArEO8IP_X yNt7PTMoztCZU6_c.E_J7zTkkRNTSoroiVEZRusqwWvdGDBDJkPKHMqhflWk.Svbx0Xm.AdHFbqd kV0TpuVbURngcibfjjM08gw8G5SK9u_SXiupZXY8uADHH6nF0hRff6PeLoh4yAN9jpQ1NoKTroMp uhsCUa0LEOOquK6.xX8ykVCc- Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.bf2.yahoo.com with HTTP; Tue, 16 Jun 2020 15:42:22 +0000 Date: Tue, 16 Jun 2020 15:42:18 +0000 (UTC) From: Pepe TD Vo Reply-To: Pepe TD Vo To: Christopher Browne Cc: Pgsql-admin Message-ID: <1761277119.1163490.1592322138731@mail.yahoo.com> In-Reply-To: References: <866581879.1147164.1592317256828.ref@mail.yahoo.com> <866581879.1147164.1592317256828@mail.yahoo.com> <1f5f4fd6-ad22-4823-c922-17a021c2c0d7@aklaver.com> <74046808.1129536.1592317823808@mail.yahoo.com> <3625e291-8456-3831-6205-2d73232bcd1e@aklaver.com> <1718146430.1151531.1592319564343@mail.yahoo.com> Subject: Re: create batch script to import into postgres tables MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1163489_1974465649.1592322138729" X-Mailer: WebService/1.1.16119 YMailNorrin Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 Content-Length: 11960 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk ------=_Part_1163489_1974465649.1592322138729 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Yes, I do have putty installed but can't connect to the aws postgres instan= ce.=C2=A0 Only work for oracle instance.=C2=A0 Only connect postgres instan= ce using pgadmin. follow the url and the login prompt for username and hung there. thank you. Bach-Nga No one in this world is pure and perfect.=C2=A0 If you avoid people for the= ir mistakes you will be alone. So judge less, love, and forgive more.To cal= l 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 =20 On Tuesday, June 16, 2020, 11:17:21 AM EDT, Christopher Browne wrote: =20 =20 =20 On Tue, 16 Jun 2020 at 10:59, Pepe TD Vo wrote: I can run \copy=C2=A0in Linux with individual csv file into the table fine = and run import using pgadmin into AWS instance.=C2=A0=C2=A0I am trying to r= un \copy all csv files import into its own table in Linux and in AWS instan= ce.=C2=A0If all csv files into one table is fine but each csv for each tabl= e.=C2=A0=C2=A0Should I create one batch job for each imported table?=C2=A0 = If each batch file import csv to its table would be fine via=C2=A0\copy tab= le_name(col1, col2, ... coln) from '/path/tablename.csv' delimiter ',' csv = header;=C2=A0=C2=A0right? There is no single straightforward answer to that. Supposing I want a batch to either all be processed, or to all not process,= then I might write a sql file like: begin;\copy table_1 (c1, c2, c3) from '/path/tabledata1.csv' csv header;\co= py table_2 (c1, c2, c3) from '/path/tabledata2.csv' csv header;\copy table_= 3 (c1, c2, c3) from '/path/tabledata3.csv' csv header;commit; But you may be fine with having a separate SQL script for each table. There will be conditions where one or the other is more appropriate, and th= at will be based on the requirements of the process. Also, the problem is I can't pull/execute psql from window client to pull t= he psql in aws instance and don't know how to create the batch script for t= his run.=C2=A0 I tried simple \copy pull from c:\tes.csv and psql is unknow= n. You cannot run psql without having it installed; there is a Windows install= er for PostgreSQL, so you could use that to get it installed. Hopefully there is an installer that will just install PostgreSQL client so= ftware (like psql, pg_dump, and notably *not* the database server software)= ; I don't use WIndows, so I am not too familiar with that. =C2=A0--=20 When confronted by a difficult problem, solve it by reducing it to the question, "How would the Lone Ranger handle this?" =20 ------=_Part_1163489_1974465649.1592322138729 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Yes, I do have putty installed bu= t can't connect to the aws postgres instance.  Only work for oracle in= stance.  Only connect postgres instance using pgadmin.

follow the url and the login prompt for username and hung there.
=

thank you.

Bach-Nga<= br clear=3D"none">
No one in this world is pure and p= erfect.  If you avoid people for their mistakes you will be alone. So = judge less, love, and forgive more.3D"Emoji"= 3D"Emoji"3D"Emoji"
To call him a dog hardly seems t= o 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)
<= br clear=3D"none">**Live simply **Love generously **Car= e deeply **Speak kindly.
*** Genuinely rich= *** Faithful talent *** Sharing success




=20
=20
On Tuesday, June 16, 2020, 11:17:21 AM EDT, Christopher= Browne <cbbrowne@gmail.com> wrote:



On Tue, 16 Jun 2020 at = 10:59, Pepe TD Vo <pepevo= @yahoo.com> wrote:
I= can run \copy in Linux with individual csv file into the = table fine and run import using pgadmin into AWS instance.  I am trying to run \copy all csv files import into its own table i= n Linux and in AWS instance. If all csv files into one table is = fine but each csv for each table.  Should I create one bat= ch job for each imported table?  If each batch file import csv to its = table would be fine via \copy table_name(col1,= col2, ... coln) from '/path/tablename.csv' delimiter ',' csv header; =  right?

There is no single straightforward answer to that.

Supposing I want a batch to either all be p= rocessed, or to all not process, then I might write a sql file like:
<= div>
begin;
\copy table_1 (c1, c2, c= 3) from '/path/tabledata1.csv' csv header;
\copy table_2 (c1= , c2, c3) from '/path/tabledata2.csv' csv header;
\copy table_3 (c1, c2, c3) from '/path/tabledata3.csv' csv header;
commit;

But you may be fine wit= h having a separate SQL script for each table.

There will be conditions where one or the other is more appropr= iate, and that will be based on the requirements of the process.

Also, the problem is I c= an't pull/execute psql from window client to pull the psql in aws instance = and don't know how to create the batch script for this run.  I tried s= imple \copy pull from c:\tes.csv and psql = is unknown.


You cannot run= psql without having it installed; there is a Windows installer for Postgre= SQL, so you could use that to get it installed.

Hopefully there is an installer that will just install Postgre= SQL client software (like psql, pg_dump, and notably *not* the database ser= ver software); I don't use WIndows, so I am not too familiar with that.
 
--
When confronted by a difficu= lt problem, solve it by reducing it to the
question, "How= would the Lone Ranger handle this?"

------=_Part_1163489_1974465649.1592322138729--