<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Outputting from Postgres to CSV</title>
	<atom:link href="http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/feed" rel="self" type="application/rss+xml" />
	<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv</link>
	<description>Random witterings from pookey</description>
	<lastBuildDate>Tue, 27 Jul 2010 16:31:55 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Ram</title>
		<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/comment-page-1#comment-1034</link>
		<dc:creator>Ram</dc:creator>
		<pubDate>Mon, 24 May 2010 20:22:10 +0000</pubDate>
		<guid isPermaLink="false">http://pookey.co.uk/wordpress/?p=51#comment-1034</guid>
		<description>Your post was useful

Could you tell me how I can include the data in double quotes ?

\o /tmp/moocow.csv
SELECT foo,bar FROM whatever;
\o

and the output like

&quot;foo&quot;,&quot;bar&quot;
&quot;fdata&quot;,&quot;bdata&quot;
&quot;fdata1&quot;,&quot;bdata2&quot;

Appreciate your help !</description>
		<content:encoded><![CDATA[<p>Your post was useful</p>
<p>Could you tell me how I can include the data in double quotes ?</p>
<p>\o /tmp/moocow.csv<br />
SELECT foo,bar FROM whatever;<br />
\o</p>
<p>and the output like</p>
<p>&#8220;foo&#8221;,&#8221;bar&#8221;<br />
&#8220;fdata&#8221;,&#8221;bdata&#8221;<br />
&#8220;fdata1&#8243;,&#8221;bdata2&#8243;</p>
<p>Appreciate your help !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sergey</title>
		<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/comment-page-1#comment-993</link>
		<dc:creator>sergey</dc:creator>
		<pubDate>Wed, 07 Apr 2010 23:54:35 +0000</pubDate>
		<guid isPermaLink="false">http://pookey.co.uk/wordpress/?p=51#comment-993</guid>
		<description>try creating a view and using it instead of the query. hope this helps.</description>
		<content:encoded><![CDATA[<p>try creating a view and using it instead of the query. hope this helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Unais</title>
		<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/comment-page-1#comment-949</link>
		<dc:creator>Unais</dc:creator>
		<pubDate>Sat, 06 Mar 2010 12:03:14 +0000</pubDate>
		<guid isPermaLink="false">http://pookey.co.uk/wordpress/?p=51#comment-949</guid>
		<description>@Ben,

Your solution works well in version 8.4.2 and it shows a syntax error in version 8.1

copy to file command in postgresql 8.1 does not accept a query . it can copy  whole table but not a query 

do u have any solution for 8.1?</description>
		<content:encoded><![CDATA[<p>@Ben,</p>
<p>Your solution works well in version 8.4.2 and it shows a syntax error in version 8.1</p>
<p>copy to file command in postgresql 8.1 does not accept a query . it can copy  whole table but not a query </p>
<p>do u have any solution for 8.1?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ken</title>
		<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/comment-page-1#comment-564</link>
		<dc:creator>Ken</dc:creator>
		<pubDate>Tue, 15 Dec 2009 22:05:26 +0000</pubDate>
		<guid isPermaLink="false">http://pookey.co.uk/wordpress/?p=51#comment-564</guid>
		<description>I run a lot of queries from the bash command line or from scripts, so here&#039;s a tip:

If you run into this error: &quot;ERROR:  must be superuser to COPY to or from a file,&quot; try this:

echo &quot;COPY (SELECT foo from BAR) TO STDOUT with CSV HEADER&quot; &#124; psql -o filename.csv database_name</description>
		<content:encoded><![CDATA[<p>I run a lot of queries from the bash command line or from scripts, so here&#8217;s a tip:</p>
<p>If you run into this error: &#8220;ERROR:  must be superuser to COPY to or from a file,&#8221; try this:</p>
<p>echo &#8220;COPY (SELECT foo from BAR) TO STDOUT with CSV HEADER&#8221; | psql -o filename.csv database_name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michal</title>
		<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/comment-page-1#comment-559</link>
		<dc:creator>Michal</dc:creator>
		<pubDate>Tue, 08 Dec 2009 17:13:11 +0000</pubDate>
		<guid isPermaLink="false">http://pookey.co.uk/wordpress/?p=51#comment-559</guid>
		<description>Saves so much effort looking for a simple example!</description>
		<content:encoded><![CDATA[<p>Saves so much effort looking for a simple example!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/comment-page-1#comment-387</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 27 Feb 2009 22:42:01 +0000</pubDate>
		<guid isPermaLink="false">http://pookey.co.uk/wordpress/?p=51#comment-387</guid>
		<description>I also can never remember how to do this, and I always google it, and end up here.  So, thank you for keeping this handy!!!</description>
		<content:encoded><![CDATA[<p>I also can never remember how to do this, and I always google it, and end up here.  So, thank you for keeping this handy!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://pookey.co.uk/wordpress/archives/51-outputting-from-postgres-to-csv/comment-page-1#comment-206</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Thu, 05 Jun 2008 10:57:36 +0000</pubDate>
		<guid isPermaLink="false">http://pookey.co.uk/wordpress/?p=51#comment-206</guid>
		<description>After much pain with line endings:

COPY (SELECT foo,bar FROM whatever)   TO &#039;/tmp/dump.csv&#039; WITH CSV HEADER</description>
		<content:encoded><![CDATA[<p>After much pain with line endings:</p>
<p>COPY (SELECT foo,bar FROM whatever)   TO &#8216;/tmp/dump.csv&#8217; WITH CSV HEADER</p>
]]></content:encoded>
	</item>
</channel>
</rss>
