Re: load fom csv - Mailing list pgsql-general

From Francisco Olarte
Subject Re: load fom csv
Date
Msg-id CA+bJJbzkpHw9n=_pb1vDukgty1_r6pjt1F9=MniVAYkiVjfdPA@mail.gmail.com
Whole thread Raw
Responses Re: load fom csv
List pgsql-general


On Mon, 16 Sept 2024 at 17:36, Andy Hartman <hartman60home@gmail.com> 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.

pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: load fom csv
Next
From: Andy Hartman
Date:
Subject: Re: load fom csv