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 1sqE1O-007yWq-JA for pgsql-general@arkaria.postgresql.org; Mon, 16 Sep 2024 15:52:15 +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 1sqE1N-00GCRZ-5w for pgsql-general@arkaria.postgresql.org; Mon, 16 Sep 2024 15:52:13 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sqE1M-00GCRP-6s for pgsql-general@lists.postgresql.org; Mon, 16 Sep 2024 15:52:12 +0000 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sqE1I-001TCV-0H for pgsql-general@lists.postgresql.org; Mon, 16 Sep 2024 15:52:10 +0000 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2f75c6ed397so47479531fa.2 for ; Mon, 16 Sep 2024 08:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peoplecall-com.20230601.gappssmtp.com; s=20230601; t=1726501926; x=1727106726; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=y5Mo9sAGO3d4Jw7j+37ZJFQd0Cytzo1Hu6WuauXeBAc=; b=TqAko1MON3nRKJ/rAWzvQwt9AMk7AQSVsaZm19bG/LhJv0gkVrCIwxvXlnsKAge2tT Eo4qL6hTXdrCScrdIlen1Cu+GmD7ZUgy9vGf1fEvsLId0fMXL1vZTLqFS8jURZ9Qz6q8 pNHjkpoYIs3m++E7JfXnlZW4+bUuRzD+hWcpc4FAmrhNa4bQ/x+nAvtP/EsURyu7J3PB VcfGbYvckjxww63vcDkxUu/9XSgSJEOYToQ674tDj2ew7yGtTZXv16b5JoIVeyXamwOP m+i2RDqeNmZjAlrXyMAwFbskbCyqQGWi4elzKI8L0puQKT5wYXWJTernaQnsWoBNO42L +EtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726501926; x=1727106726; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=y5Mo9sAGO3d4Jw7j+37ZJFQd0Cytzo1Hu6WuauXeBAc=; b=p2gy0JC8mb8PLpxKEvxCWJ2uYOERFPwQ/df/+M3zEIpud9us+Csk0PZnyscu8RVoIm vz2Tyk+oKfdrRRwPBWSIFeyvPQ6M9HtKPOza6IvPpUmBo6SbfMwwMhSy+G1/FmkxvFZ8 PTzVT+dgK6pnA4liOuD0NgKk+nLwQddZiQU3uinWshaYAzOvT7p4xF2nHH9T/3f9tg98 Z1FVWHk0gXzoTBNWEXzxM2GSZlzbepzrx+715LIKejiHLJ1+fDJq+KOYtMDXCJqEkBOw j4rLZPX/karEqoaBRFhbWE7eyN2x7HNyuTtWzgyYVmw+SOqDvxfmpeebmkJXXUw0oy2O zuYA== X-Gm-Message-State: AOJu0YwQaQfFwhe+JtwfGqo6n7TGxr0fx5LUmtrEXjjefJmPKb5w0mzV wOAPjrY9oEmPRkcKUZd7nEuIyb0BFwKJbwpXjTGgLQOxLmpC7A8roiGgmTLwdd4QNufK25sS5Rb IZ371RdBiBxHPn7JwFF8VBcc0RHKN8R+nGlZP X-Google-Smtp-Source: AGHT+IGc9OAwZp2iyX+iF/UL5TgkkfhbA4FJFkNsxu71CzB/r5FndNC/zkJL7haew+cHls3+Dmfn65A8PQz8PpYKteM= X-Received: by 2002:a05:651c:b0c:b0:2f3:f193:d2d0 with SMTP id 38308e7fff4ca-2f787f2dacfmr80531821fa.33.1726501925168; Mon, 16 Sep 2024 08:52:05 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Francisco Olarte Date: Mon, 16 Sep 2024 17:51:28 +0200 Message-ID: Subject: Re: load fom csv To: Andy Hartman Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="000000000000f4520506223e8d8c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000f4520506223e8d8c Content-Type: text/plain; charset="UTF-8" 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. --000000000000f4520506223e8d8c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Mon, 16 Sept 2024 at 17:36, Andy= Hartman <h= artman60home@gmail.com> wrote:
I'm trying to r= un this piece of code from Powershell and it just sits there and never come= s back. There are only 131 records in the csv.
$connectionString = =3D "Host=3D$pgServer;Database=3D$pgDatabase;Username=3D$pgUser;Passwo= rd=3D$pgPassword"
$copyCommand =3D "\COPY $pgTable FROM= '$csvPath' DELIMITER ',' CSV HEADER;"
psql = -h $pgServer -d $pgDatabase -U $pgUser -c $copyCommand=C2=A0
how = can I debug this?=C2=A0=C2=A0

=
I would start by adding -a and -e after "psql".

IIRC Pow= ershell is windows, and in windows shell do not pass command words preparse= d as in *ix to the executable, but a single command line with the executabl= e must parse. Given the amount of quoting, -a and -e will let you see the c= ommands 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 messa= ge, and psql might be waiting for a password.

Francisco Olarte.<= /div>

--000000000000f4520506223e8d8c--