Local Machine(l1): Windows 10 psql

Remote Machine(R1): linux EDB(postgres)

On my local I have 1000+ sql script containing insert statement . psql is also installed locally . I need to run this sql script from my local command prompt using psql client . I can connect to remote db as psql -h hostnme -U username -p port DBName . For single file i know that it can be run like \i f.sql . I also tried combining all sql file in one file on windows using command copy /b *.sql new.sql . But the new sql file size is 4 GB . Which is not easy to work with . Is there any way I can run those 1000+ sql script from psql without combining from command prompt ?

  • Write a loop in something like Powershell and call psql -f <filename> 1000 times. Jul 6, 2020 at 13:43
  • I am connecting to remote DB with a host, port, username and password .
    – user236778
    Jul 6, 2020 at 14:22
  • The only issue is passing password . How can I avoid passing password 1000 times ?
    – user236778
    Jul 6, 2020 at 14:36
  • Why is that a problem? You can use the PGPASSWORD environment variable. Jul 6, 2020 at 14:44


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.