public inbox for [email protected]help / color / mirror / Atom feed
load fom csv 4+ messages / 4 participants [nested] [flat]
* load fom csv @ 2024-09-16 15:35 Andy Hartman <[email protected]> 0 siblings, 3 replies; 4+ messages in thread From: Andy Hartman @ 2024-09-16 15:35 UTC (permalink / raw) To: [email protected] 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] Attachments: [image/png] image.png (65.2K, 3-image.png) download | view image ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: load fom csv @ 2024-09-16 15:45 Adrian Klaver <[email protected]> parent: Andy Hartman <[email protected]> 2 siblings, 0 replies; 4+ messages in thread From: Adrian Klaver @ 2024-09-16 15:45 UTC (permalink / raw) To: Andy Hartman <[email protected]>; [email protected] On 9/16/24 08:35, 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? 1) Look at the Postgres log. 2) Run the psql command outside PowerShell with hard coded connection values and -c command. > > Table layout > > image.png -- Adrian Klaver [email protected] ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: load fom csv @ 2024-09-16 15:47 Ron Johnson <[email protected]> parent: Andy Hartman <[email protected]> 2 siblings, 0 replies; 4+ messages in thread From: Ron Johnson @ 2024-09-16 15:47 UTC (permalink / raw) To: pgsql-generallists.postgresql.org <[email protected]> On Mon, Sep 16, 2024 at 11:36 AM Andy Hartman <[email protected]> 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? > Maybe I'm missing something obvious, but where in the psql command are you using $connectionString? -- Death to <Redacted>, and butter sauce. Don't boil me, I'm still alive. <Redacted> crustacean! ^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: load fom csv @ 2024-09-17 05:55 Muhammad Usman Khan <[email protected]> parent: Andy Hartman <[email protected]> 2 siblings, 0 replies; 4+ messages in thread From: Muhammad Usman Khan @ 2024-09-17 05:55 UTC (permalink / raw) To: Andy Hartman <[email protected]>; +Cc: [email protected] 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 <[email protected]> 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] > Attachments: [image/png] image.png (65.2K, 3-image.png) download | view image ^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-09-17 05:55 UTC | newest] Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-09-16 15:35 load fom csv Andy Hartman <[email protected]> 2024-09-16 15:45 ` Adrian Klaver <[email protected]> 2024-09-16 15:47 ` Ron Johnson <[email protected]> 2024-09-17 05:55 ` Muhammad Usman Khan <[email protected]>
This inbox is served by agora; see mirroring instructions for how to clone and mirror all data and code used for this inbox