var pg = require('pg');
var conString = process.env.DATABASE_CONNECTION_URL;







exports.delphidata =  function (req, res) {
  var client = new pg.Client(conString);
  client.connect(function(err) {
      if (err) {
          console.error('could not connect to postgres', err);
      } else {
          console.log("Successfully connected to postgres")
      }

  });

  client.query("SELECT gender, number_of_respondents FROM cogs121_16_raw.cdph_smoking_prevalence_in_adults_1984_2013 WHERE year = 2013 ORDER BY number_of_respondents ASC",function(err,dat){
        client.end();
        console.log(dat);
        res.json(dat.rows);
    });
  return { delphidata: "No data present." }
}
