Re: Data in a table to a csv file - Mailing list pgsql-general

From Joshua Berry
Subject Re: Data in a table to a csv file
Date
Msg-id 4A3B66FF-A5C8-4061-BC02-F8C9971271A9@gmail.com
Whole thread Raw
In response to Data in a table to a csv file  (aravind chandu <avin_friends@yahoo.com>)
Responses Re: Data in a table to a csv file  (Steve Crawford <scrawford@pinpointresearch.com>)
List pgsql-general
           I have a small problem,I need to export data from a table into a csv file.For this i am using pqxx library to work on it.I can able to retrieve the data from the database but the only problem is I am unable to store it in a csv file.Can you guys please help me how to do that.

I'm no Postgresql expert, but I've used the builtin "COPY" SQL command. You can find the documentation on it here: http://www.postgresql.org/docs/8.3/interactive/sql-copy.html

Note:
1. Using COPY in this way is that Postgresql will create the csv file on the server's filesystem, not on your client machine, if you use a different machine for server and client.
2. when you create the file, the directory that you create the file in must be writable by Postgres, I just always use /tmp as anyone can create files in that directory.
3. #2 is probably specific to UNIX environments like Linux or MacOS X.

HTH,

-Joshua

Joshua Berry

pgsql-general by date:

Previous
From: aravind chandu
Date:
Subject: Data in a table to a csv file
Next
From: Marsh Ray
Date:
Subject: Commit visibility guarantees