title: nodejs mysql how to read config parameters
body: <pre><code>var iniparser = require('iniparser');
  var config = iniparser.parseSync('../Config/init/db.ini');
  var env = process.env.NODE_ENV || 'dev'; //startup nodejs with e.g:  NODE_ENV= node server.js
  
  var app                 = require('http').createServer(handler),
  io                  = require('socket.io').listen(app),
  fs                  = require('fs'),
  mysql               = require('mysql'),
  connectionsArray    = [],
  connection          = mysql.createConnection({
      host        : config[env]['host'],
      user        : config[env]['user'],
      password    : config[env]['pwd'],
      database    : config[env]['dbname']
  }),
  POLLING_INTERVAL = 3000,
  pollingTimer;    
  
  console.log(config[env]['host']);
  console.log(config[env]['user']);
  console.log(config[env]['pwd']);
  console.log(config[env]['dbname']);
  
  // If there is an error connecting to the database
  connection.connect(function(err) {
    // connected! (unless `err` is set)
    console.log( err );
  });
  </code></pre>
  
  <p>db.ini</p>
  
  <pre><code> [dev]
   host = "localhost"
   user = "root"
   pwd =  "root"
   dbname = "db_local"
  </code></pre>
  
  <p>output from console.log:</p>
  
  <pre><code>"localhost"
  "root"
  "root"
  "tittilate_local"
  </code></pre>
  
  <p>This top part of my nodejs script. console.log is outputting fine but connection is not established.
  Somehow the config variable is not recognized within createConnection.</p>
  
  <p>Anybody has a suggestion ?</p>