title: Import CSV to postgresql (Zend/PHP)
body: <p>I want to load test data into a table in my postgresql database. </p>
  
  <p>I am doing this inside my unit test class.</p>
  
  <pre><code>$this-&gt;Application_Model_UserMapper-&gt;getDbTable()-&gt;getAdapter()-&gt;query("COPY users FROM '" . APPLICATION_PATH . "/../tests/dbtestdata/users.csv' CSV HEADER NULL AS E'\N'");
  </code></pre>
  
  <p>and I get an error message that says I must be a super user to copy to and from a file. Does that mean I need to log in as postgres user? I have read that that could cause security issues, so I am not keen on doing that.</p>
  
  <p>Other option seems to be \COPY, but the following doesnt work..</p>
  
  <pre><code>$this-&gt;Application_Model_UserMapper-&gt;getDbTable()-&gt;getAdapter()-&gt;query("
  
    \COPY users FROM '" . APPLICATION_PATH . "/../tests/dbtestdata/users.csv' 
    CSV HEADER NULL AS E'\N'
  
  ");
  </code></pre>
  
  <p>I get a syntax error. </p>