Writing to file from Redshift using Psycopg2 throwing exception
<p>I am using Python 2.6 where I want to read data from Redshift from a table called "user_data" &amp; write to a file using psycopg2. I get the records in "cursor" &amp; in this way I try to write to file :</p>

<pre><code>fout = open('user_data', 'w')
cursor.copy_to(fout,"user_data", sep='|')
</code></pre>

<p>When I execute this,it throws following error:</p>

<pre><code>psycopg2.ProgrammingError: syntax error at or near "stdout"
LINE 1: COPY user_data TO stdout WITH DELIMITER AS
</code></pre>

<p>What does it wants to tell ?? Whats the solution to this one ??</p>