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 1sqEsY-0085IV-R2 for pgsql-general@arkaria.postgresql.org; Mon, 16 Sep 2024 16:47:11 +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 1sqEsX-00GO3G-3t for pgsql-general@arkaria.postgresql.org; Mon, 16 Sep 2024 16:47:09 +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 1sqEsW-00GO38-GX for pgsql-general@lists.postgresql.org; Mon, 16 Sep 2024 16:47:08 +0000 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sqEsT-001U1n-9W for pgsql-general@lists.postgresql.org; Mon, 16 Sep 2024 16:47:07 +0000 Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-e1a7e54b898so3759426276.2 for ; Mon, 16 Sep 2024 09:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726505225; x=1727110025; 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=Z+6EVBfkGV+v1zWEn8sYubEViMRBbK07qouMdiDlScs=; b=RrS1CGgfEwEFuKgC79wdL40xkprM+81yP5BVxpigYsi+Qi+3htUdpbh8nstChmnuOR OZL74chsshw2CBS6luIIBGBMOqPJFckHXoQyEofxdZVfJc7ALwuNBy7bZKn3M3Uc49Ex 4K74h23nOs8APvkD/h6Xm6g3qd0718MjarWlnfU7BsUK/6cU+DnH6Cf7tYXwGYnWpX+c X+2XCmHpTIaS9nek9H8J45Hs4xVrJXmLAaIe9/cCLxWmE2QO1ShZSz0tkxnak+vf6bq6 cUwvLrxrqSBwUpFefpKwh+6BeDS8C6UsOiYTUVX0bFITvr+/Q2Ovhp41yKTiQ163Nkco dYNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726505225; x=1727110025; 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=Z+6EVBfkGV+v1zWEn8sYubEViMRBbK07qouMdiDlScs=; b=v5WMMhatTHQhFYIHZYHpCitYtwh1KEl5XZVNNi7I+F9/N+zdbjgjWcrtgdz8aZkvYp De7UdmG1cRE6CF1oPUfbAXuB9L6i3J0MonC8MU27LsW0Uc+Xja+9nEcS9kGoQWIMKjCI lxwTWaL59q2z9wB5jqCw6BeNVa7/81ckfElztp9j152lI0HHsWjaXeUxufl58QX7MChS urtchshwWuUdRfWgs8e3YX62gWXbcs++DFaCjNGCYozdK65vCw6dSAAbYfqu0d2CGA42 rhbndmoA6Sru57jvVsejaysJLqAuIc/9cijEQf0PGfiFH3JMh22lDNvjcuim5IhpdgDa 2rLw== X-Forwarded-Encrypted: i=1; AJvYcCVy00mbOzo4OtWkNcn49Bs83obszSocthnKZnWuB+ATsXQYCCxyxKQ6mgRNsUa/MrV4bEyQY1oT2w2OkcK2@lists.postgresql.org X-Gm-Message-State: AOJu0YyWOhlzZsbIldlaD8z/AfN5+524IGs5XeG5aXamkyyJRF9FgN+I MFphPYb/5VN84ye/Q7Lw/ikchNqr1HK4sZwgpDC061+4lkf0Otb1i2C+Y72NtN+G8KxrwR+TxZb 73aFVC2JwRf1XAWPnKXBMRg38vqqLrpyBTGs= X-Google-Smtp-Source: AGHT+IF3AJ7FZyZnnphAalE+q46dU6M0/XtLDFXfT32Js5T1d3HbF18hiHt7yOowJNVrNpROqq3P9pDRTpvrEjY0z+o= X-Received: by 2002:a05:6902:722:b0:e20:1424:64f0 with SMTP id 3f1490d57ef6-e2014246589mr111195276.16.1726505224641; Mon, 16 Sep 2024 09:47:04 -0700 (PDT) MIME-Version: 1.0 References: <9f5a968f-bd6d-49b6-b5b7-7e5a355f445a@aklaver.com> In-Reply-To: <9f5a968f-bd6d-49b6-b5b7-7e5a355f445a@aklaver.com> From: Andy Hartman Date: Mon, 16 Sep 2024 12:46:53 -0400 Message-ID: Subject: Re: load fom csv To: Adrian Klaver Cc: Francisco Olarte , pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000009e22b906223f52f7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000009e22b906223f52f7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable It Looks correct. $pgTable =3D "image_classification_master" On Mon, Sep 16, 2024 at 12:17=E2=80=AFPM 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-SYNTA= X-IDENTIFIERS > > for why. > > > > > On Mon, Sep 16, 2024 at 11:52=E2=80=AFAM 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 jus= t > > sits there and never comes back. There are only 131 records in > > the csv. > > $connectionString =3D > > > "Host=3D$pgServer;Database=3D$pgDatabase;Username=3D$pgUser;Password=3D$= pgPassword" > > $copyCommand =3D "\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 comman= d > > 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 i= s > > trying to read something what it is. > > > > I will also try to substitute the -c with a pipe. If it heals, it i= s > > 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 > > --0000000000009e22b906223f52f7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
It Looks correct.

$pgTable =3D "image_classif= ication_master"




On Mon, Sep 16, 2024 at 12:17=E2=80=AFPM Adrian Klaver <adrian.klaver@aklaver.com> wro= te:
On 9/16/24 0= 9:12, Andy Hartman wrote:
> 2024-09-16 12:06:00.968 EDT [4968] ERROR:=C2=A0 relation
> "image_classification_master" does not exist
> 2024-09-16 12:06:00.968 EDT [4968] STATEMENT:=C2=A0 COPY=C2=A0
> Image_Classification_Master FROM STDIN DELIMITER ',' CSV HEADE= R;

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.po= stgresql.org/docs/current/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

for why.

>
> On Mon, Sep 16, 2024 at 11:52=E2=80=AFAM Francisco Olarte
> <
folart= e@peoplecall.com <mailto:folarte@peoplecall.com>> wrote:
>
>
>
>=C2=A0 =C2=A0 =C2=A0On Mon, 16 Sept 2024 at 17:36, Andy Hartman <hartman60home@gma= il.com
>=C2=A0 =C2=A0 =C2=A0<mailto:hartman60home@gmail.com>> wrote:
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0I'm trying to run this piece of c= ode from Powershell and it just
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0sits there and never comes back. Ther= e are only 131 records in
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0the csv.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$connectionString =3D
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0"Host=3D$pgServer;Database=3D$pg= Database;Username=3D$pgUser;Password=3D$pgPassword"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$copyCommand =3D "\COPY $pgTable= FROM '$csvPath' DELIMITER ',' CSV
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0HEADER;"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0psql -h $pgServer -d $pgDatabase -U $= pgUser -c $copyCommand
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0how can I debug this?
>
>
>=C2=A0 =C2=A0 =C2=A0I would start by adding -a and -e after "psql&= quot;.
>
>=C2=A0 =C2=A0 =C2=A0IIRC Powershell is windows, and in windows shell do= not pass command
>=C2=A0 =C2=A0 =C2=A0words preparsed as in *ix to the executable, but a = single command
>=C2=A0 =C2=A0 =C2=A0line with the executable must parse. Given the amou= nt of quoting, -a
>=C2=A0 =C2=A0 =C2=A0and -e will let you see the commands are properly s= ent, and if it is
>=C2=A0 =C2=A0 =C2=A0trying to read something what it is.
>
>=C2=A0 =C2=A0 =C2=A0I will also try to substitute the -c with a pipe. I= f it heals, it is
>=C2=A0 =C2=A0 =C2=A0probably a quoting issue.
>
>=C2=A0 =C2=A0 =C2=A0Also, I just caught Ron's message, and psql mig= ht be waiting for a
>=C2=A0 =C2=A0 =C2=A0password.
>
>=C2=A0 =C2=A0 =C2=A0Francisco Olarte.
>

--
Adrian Klaver
adrian.klave= r@aklaver.com

--0000000000009e22b906223f52f7--