Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqF1k-0086OW-B0 for pgsql-general@arkaria.postgresql.org; Mon, 16 Sep 2024 16:56:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sqF1j-00GR67-6l for pgsql-general@arkaria.postgresql.org; Mon, 16 Sep 2024 16:56:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqF1h-00GR5y-L4 for pgsql-general@lists.postgresql.org; Mon, 16 Sep 2024 16:56:38 +0000 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqF1Y-001Vnt-Ac for pgsql-general@lists.postgresql.org; Mon, 16 Sep 2024 16:56:36 +0000 Received: from phl-compute-12.internal (phl-compute-12.phl.internal [10.202.2.52]) by mailfout.phl.internal (Postfix) with ESMTP id 0B0BA138028D; Mon, 16 Sep 2024 12:56:27 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-12.internal (MEProxy); Mon, 16 Sep 2024 12:56:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1726505787; x=1726592187; bh=ESbUEbQm60f0xBTmr5BgpU57rN+WM+IrhyVPcTDR8r4=; b= qK4VWH/uL48KMjnaqOqibtgDrIJCOLBAHDbq7NdnRnZnoL9lz/4p9gTn6Fj27hWW NhjF5VpmS8sZwAUsHTGamSMvW3BcRuerESd5tIC9rhvttB3QHJ5al9maE8kNFPOP iUUGVgVMAQ8PawP3Rny7qFhsUStKqF9RPj0blrzq6pqwaXCK5C/TjdTkkoqx3KJ1 RtEY7MJbgwOVC6u42OvDn54dRMBySdIfqFyP+sSHuYOQNNWe5jIhROgbTYfdyb7F Yd25+uTnmAk1tjiGxaafQezbEmQCqtpkW4BkhvppWxIy5zfQNIJRlWzMk9tKKjD2 f4RnIrfip90fv1hAXNgHhQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1726505787; x= 1726592187; bh=ESbUEbQm60f0xBTmr5BgpU57rN+WM+IrhyVPcTDR8r4=; b=P 02hpz+cfZEK3aiieAhhIt1YERGz8f3tNH0hPY8aAGMb/T7sM9KAdjZrKF6s5tygj Pp3JesISGrklJjz5pN7YqQrqMqaLPk7tb8NIphYoh4LBc+YQD1mipPcjI5guJqUN 0mNbV7daoHxlya8qZfBxHm9g92rVD0tGUCjn4pX6C4kMylwolAAGJ28betwS+TmT 1cpb5lVUgu0p+YZm/G6La+ksVP7bH4Nb4PpDXy6G/AWHSK+ISevg8FYtg58wlmua jkMguPaV4P2Nbb04lpUQj1FD0JUWZp+aeEftcXFp7yB5b02+xBvHNgou6mb0IUj6 3wlRQt1zAPMTJ06Els57w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudekhedguddthecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefkffggfgfuvfevfhfhjggtgfesthekredttddv jeenucfhrhhomheptegurhhirghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvg hrsegrkhhlrghvvghrrdgtohhmqeenucggtffrrghtthgvrhhnpefgudefkefhveefleev ieeuveehvdduudekuddvvdelhfeuueeijedtuedvvedvueenucffohhmrghinhepphhosh htghhrvghsqhhlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomhdpnh gspghrtghpthhtohepfedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohephhgrrhht mhgrnheitdhhohhmvgesghhmrghilhdrtghomhdprhgtphhtthhopehfohhlrghrthgvse hpvghophhlvggtrghllhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhgvghnvghrrghl sehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 Sep 2024 12:56:26 -0400 (EDT) Message-ID: <48ab0c54-3bf1-451b-87d6-1b7d9b5e5e67@aklaver.com> Date: Mon, 16 Sep 2024 09:56:25 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: load fom csv To: Andy Hartman Cc: Francisco Olarte , pgsql-general@lists.postgresql.org References: <9f5a968f-bd6d-49b6-b5b7-7e5a355f445a@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 9/16/24 09:46, Andy Hartman wrote: > > It Looks correct. > > $pgTable = "image_classification_master" Connect to the database with psql and look at the table name. I'm betting it is not image_classification_master. Instead some mixed or all upper case version of the name. I don't use PowerShell or Windows for that matter these days so I can't be of much use on the script. I do suspect you will need to some escaping to get the table name properly quoted in the script. To work through this you need to try what I call the crawl/walk/run process. In this case that is: 1) Crawl. Connect using psql and run the \copy in it with hard coded values. 2) Walk. Use psql with the -c argument and supply the command again with hard coded values 3) Run. Then use PowerShell and do the variable substitution. > > > > > On Mon, Sep 16, 2024 at 12:17 PM Adrian Klaver > > wrote: > > On 9/16/24 09:12, Andy Hartman wrote: > > 2024-09-16 12:06:00.968 EDT [4968] ERROR:  relation > > "image_classification_master" does not exist > > 2024-09-16 12:06:00.968 EDT [4968] STATEMENT:  COPY > > Image_Classification_Master FROM STDIN DELIMITER ',' CSV HEADER; > > I'm assuming this is from the Postgres log. > > Best guess is the table name in the database is mixed case and needs to > be double quoted in the command to preserve the casing. > > See: > > https://www.postgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS > > for why. > > > > > On Mon, Sep 16, 2024 at 11:52 AM Francisco Olarte > > > >> wrote: > > > > > > > >     On Mon, 16 Sept 2024 at 17:36, Andy Hartman > > >      >> wrote: > > > >         I'm trying to run this piece of code from Powershell and > it just > >         sits there and never comes back. There are only 131 > records in > >         the csv. > >         $connectionString = > > >  "Host=$pgServer;Database=$pgDatabase;Username=$pgUser;Password=$pgPassword" > >         $copyCommand = "\COPY $pgTable FROM '$csvPath' DELIMITER > ',' CSV > >         HEADER;" > >         psql -h $pgServer -d $pgDatabase -U $pgUser -c $copyCommand > >         how can I debug this? > > > > > >     I would start by adding -a and -e after "psql". > > > >     IIRC Powershell is windows, and in windows shell do not pass > command > >     words preparsed as in *ix to the executable, but a single command > >     line with the executable must parse. Given the amount of > quoting, -a > >     and -e will let you see the commands are properly sent, and > if it is > >     trying to read something what it is. > > > >     I will also try to substitute the -c with a pipe. If it > heals, it is > >     probably a quoting issue. > > > >     Also, I just caught Ron's message, and psql might be waiting > for a > >     password. > > > >     Francisco Olarte. > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com > -- Adrian Klaver adrian.klaver@aklaver.com