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 1jlDF2-0000qh-3F for pgsql-admin@arkaria.postgresql.org; Tue, 16 Jun 2020 15:11:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jlDF0-0006n6-Ss for pgsql-admin@arkaria.postgresql.org; Tue, 16 Jun 2020 15:11:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlDF0-0006mv-Ju; Tue, 16 Jun 2020 15:11:10 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jlDEx-0007AG-IR; Tue, 16 Jun 2020 15:11:10 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 36C545C2; Tue, 16 Jun 2020 11:11:05 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 16 Jun 2020 11:11:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm3; bh=m 7trK3kUxs82KJGHpmL7lWP6+XN142setohxvIqw+DY=; b=T64LFv55jtJt4hq18 J9bn1zZJT4aiIsOKfbqtCby2W0vEAYWsyp6Uvfqc8xmxcTQ6aDmY6jIpmD6DXESC evYU4ZeyzX+/d3e57Cb3H2/Mz93AJRrVYUU6QEj/0D3WFYP4+IWtApF+pCAj7RDk aU5HMb9+FhU0RyaPnDqZNP28Q2cY2Hyl6UsmRX+eigDJ0y8Q6hM0TwrLwJKRxcch mjbfpA3SbJth3avZYIO4FFxNHR0tej99Nxiyvma1rUmXTKtUKwIF66bKj6uJ5woZ UaHzxWOhESE7AXjDSBZGqbwQxhX2U94k+hKdrtVzf3v3qH038+7ezczDh0u/EDYM Kq0Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=m7trK3kUxs82KJGHpmL7lWP6+XN142setohxvIqw+ DY=; b=A5GhHe7O7UrcFEAqlxG33tH4B+v5MVntjyU9xp3ISdOUNmX1B4VyfAcRZ gLOv1xhxF+2iT5InWntefsWy/EgbuKMjFZo+q/qL7IIeqk6qlyORrcNHKaO0tSIH Hw6llsxPPghuhAk1p/DaOTs8qIWY6ruBMab/SI7VldTtZ5i77RA6V9hQrJWyaJ5i GQ6+EKWZDzrnpSLw1xnkpTtApNaMx5yiKcbVPszXxOZFYbyvlXN+L4rriZfGjxrS 23ZKoT7Pdn3S8Hq24dKSHhvmFcjolg4VfOX6D3bKA/vZ3IIfdH+uLCORgJsXr591 4BHG3Jq7ObrVf1Y8OybeYFN8sog4A== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudejtddgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthekredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeetgfekvefgtdefheehhfeljefhtdduhffgtedtveeu uedutedvjeffjeegvdfgteenucffohhmrghinhepghhrvggvnhgvnhgurdhorhhgrdhukh dpvggrrhhthhdrlhhipdhpohhsthhgrhgvshhqlhdrohhrghenucfkphepjeehrddujedv rdehrddvfedunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Received: from [192.168.1.3] (75-172-5-231.tukw.qwest.net [75.172.5.231]) by mail.messagingengine.com (Postfix) with ESMTPA id 0297830618B7; Tue, 16 Jun 2020 11:11:03 -0400 (EDT) Subject: Re: create batch script to import into postgres tables To: Pepe TD Vo , Pgsql-general , Pgsql-admin 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> From: Adrian Klaver Message-ID: <717a7347-9eba-f850-ddf4-91bf4da174a5@aklaver.com> Date: Tue, 16 Jun 2020 08:11:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <1718146430.1151531.1592319564343@mail.yahoo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 6/16/20 7:59 AM, Pepe TD Vo wrote: Just noticed you cross posted to pgsql-admin listed. FYI, That is not a good practice. > 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 in Linux and in AWS instance. If > all csv files into one table is fine but each csv for each table. Should > I create one batch 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? Yes, you will need to copy each file into its own table. > > Also, the problem is I can'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 simple \copy pull from c:\tes.csv and psql > is unknown. There is no good/easy way I know of to install just psql on Windows. You are better off copying the CSV files to the AWS instance. Do you have PuTTY installed?: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html If not I would take a look at above link. PuTTY brings SSH to Windows. The relevant part to this issue is: https://the.earth.li/~sgtatham/putty/0.73/htmldoc/Chapter5.html#pscp "PSCP, the PuTTY Secure Copy client, is a tool for transferring files securely between computers using an SSH connection. " > > > ** > *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.EmojiEmojiEmoji > 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 Tuesday, June 16, 2020, 10:39:45 AM EDT, Adrian Klaver > wrote: > > > On 6/16/20 7:30 AM, Pepe TD Vo wrote: > Please post to list also. > Ccing list. > > > using psql in AWS instance > > also psql in Linux.  I can run psql in linux if create a batch file, but > > don't know how to pull psql in aws instance if the batch script run in > > Window client.  Also, I need help to pull each csv import to its own > > table.  Should I create each batch script for each import table? > > So the AWS instance and Linux instance are different? > > To me the simplest solution would be to push the CSV files to the AWS > instance and work from there. The files will need to be run through a > Postgres command to be imported into a table. > > Are you familiar with > COPY(https://www.postgresql.org/docs/12/sql-copy.html) or > \copy(https://www.postgresql.org/docs/12/app-psql.html)? > > > > > > ** > > *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.EmojiEmojiEmoji > > 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 Tuesday, June 16, 2020, 10:25:03 AM EDT, Adrian Klaver > > > wrote: > > > > > > On 6/16/20 7:20 AM, Pepe TD Vo wrote: > >  > good morning experts, > >  > > >  > I nêd to set up a batch script to import multi csv files to import > them > >  > to Postgres tables.  Each csv files will be named > table1_todaydate.csv, > >  > table2_todaydate.csv, etc... tablen_todaydate.csv.  Each csv file will > >  > import to its table and how do I execute the script to called psql > from > >  > AWS?  Do I need to create each batch file for import each table? > > > > You have psql installed on your local(Windows?) machine? > > > > Or are you using psql in your AWS instance? > > > >  > > >  > all export file is store in c:\export\files\ > >  > > >  > thank you. > >  > > >  > Bach-Nga > >  > > >  > > >  > > >  > > >  > > >  > > >  > ** > >  > *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.EmojiEmojiEmoji > > > >  > 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 > > > >  > > >  > > > > > > > -- > > Adrian Klaver > > adrian.klaver@aklaver.com > > > > > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com -- Adrian Klaver adrian.klaver@aklaver.com