title: app.js shows error: TypeError: Cannot call method 'query' of null
body: <p>I am new to node.js. I am trying to load a csv file values into database. It shows error as follows:</p>
  
  <p>Error: </p>
  
  <p>at<br>
  <code>var stream = client.query(copyFrom('COPY menu_list FROM STDIN'));</code></p>
  
  <blockquote>
  <pre><code>TypeError: Cannot call method 'query' of null
    at /home/sathish/backup2/backup/sappsApli/routes/index.js:487:23
    at /home/sathish/backup2/backup/sappsApli/node_modules/pg/lib/pool.js:75:25
    at /home/sathish/backup2/backup/sappsApli/node_modules/pg/node_modules/generic-pool/lib/generic-pool.js:274:11
    at /home/sathish/backup2/backup/sappsApli/node_modules/pg/lib/pool.js:27:26
    at null.&lt;anonymous&gt; (/home/sathish/backup2/backup/sappsApli/node_modules/pg/lib/client.js:172:5)
    at EventEmitter.emit (events.js:95:17)
    at Socket.&lt;anonymous&gt; (/home/sathish/backup2/backup/sappsApli/node_modules/pg/lib/connection.js:109:12)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.&lt;anonymous&gt; (_stream_readable.js:710:14)
    at Socket.EventEmitter.emit (events.js:92:17)
  </code></pre>
  </blockquote>
  
  <p>My code:   </p>
  
  <pre><code>var fs = require('fs');
  var pg = require('pg');
  var copyFrom = require('pg-copy-streams').from;
  pg.connect(function(err, client, done) {
      console.log("welcome");
    var stream = client.query(copyFrom('COPY menu_list FROM STDIN'));
    var fileStream = fs.createReadStream('list.csv')
    fileStream.on('error', done);
    fileStream.pipe(stream).on('finish', done).on('error', done);
  });
  </code></pre>
  
  <p>Can any body help to crack the issue?</p>