title: How to execute copy command from Psycopg2 on remote database connection?
body: <p>I'm running 2 <strong>docker</strong> containers.</p>
  
  <ol>
  <li><strong>Flask</strong> app - which has file volume attached.</li>
  <li><strong>Postgres</strong> database which has a database volume attached.</li>
  </ol>
  
  <p>I'm connecting to the Postgres container using <strong>Psycopg2</strong> from Flask app.
  And I have a CSV file that I want to copy to the Postgres table. This <strong>CSV</strong> file is present in the volume attached to flask app. and the postgres container has no connection to this volume.</p>
  
  <p>When I create a connection using <code>psycopg2</code> and create a <code>cursor</code> and execute the <code>copy</code> command on that table. It is trying to copy from the folder that I have in Postgres container.</p>
  
  <p>I tried <code>\copy</code> instead of <code>copy</code> for copying the data from the client container. But I'm getting <strong>Invalid syntax error</strong>. I even tried <code>\\copy</code>. That didn't work either.</p>
  
  <blockquote>
    <p>Unable to process files due to exception: syntax error at or near "\"
    LINE 1: \copy account(username,password,email) from
    '/tmp/redshift11... </p>
  </blockquote>