0

I am wondering how I can copy a table into a CSV file and send it over FTP? I have searched but either I am searching for the wrong thing or looking in the wrong places. Thanks.

Kevin Orriss
  • 281
  • 1
  • 2
  • 11
  • If you have psql client on the machine where you want the output file, just create the file by connecting to PostgreSQL from that machine. – Jayadevan Apr 16 '14 at 11:02
  • You need an FTP client that can read from a pipe to an exec'd command. Then use `psql` with `\copy`. – Craig Ringer Apr 16 '14 at 11:14

1 Answers1

0

Write a shell script or Batch file as following.

1) set PATH environment variable for PSQL or go to psql executable file using CD

2) use below command to create CSV file for particular table

  pg_dump -t TableName DBName > db.sql

for more Reference visit : pg_dump

3) This will create db.sql file.

4) now write code to connect with FTP and send this file to FTP. For this visit Batch file to upload file

Community
  • 1
  • 1
Ilesh Patel
  • 1,855
  • 15
  • 25