Re: load fom csv

From: Andy Hartman <hartman60home(at)gmail(dot)com>
To: Muhammad Usman Khan <usman(dot)k(at)bitnine(dot)net>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: load fom csv
Date: 2024-09-17 15:13:02
Message-ID: CAEZv3cq4RwUv1N1M0jzxLhTKkSnuUPQbF06ZSQeDwq6Yi1_0EQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Still when I try to run from my powershell script it hangs...

On Tue, Sep 17, 2024 at 8:31 AM Andy Hartman <hartman60home(at)gmail(dot)com>
wrote:

> I have bad data in an Int field...
>
> Thanks for your help.
>
> On Tue, Sep 17, 2024 at 1:55 AM Muhammad Usman Khan <usman(dot)k(at)bitnine(dot)net>
> wrote:
>
>> Hi,
>> Try the following options:
>>
>>
>> - Check if psql is working independently:
>> psql -h $pgServer -d $pgDatabase -U $pgUser -c "SELECT 1;"
>> - Check for permission issues on the CSV file
>> - Run the command manually without variables
>> psql -h your_host -d your_db -U your_user -c "\COPY your_table FROM
>> 'C:/path/to/your/file.csv' DELIMITER ',' CSV HEADER;"
>> - set a timeout using the PGCONNECT_TIMEOUT environment variable:
>> $env:PGCONNECT_TIMEOUT=30
>>
>>
>>
>> On Mon, 16 Sept 2024 at 20:35, Andy Hartman <hartman60home(at)gmail(dot)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?
>>>
>>> Table layout
>>>
>>> [image: image.png]
>>>
>>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-09-17 15:23:29 Re: load fom csv
Previous Message Adrian Klaver 2024-09-17 15:01:32 Re: question on plain pg_dump file usage