title: JSON output using Express using Mysql
body: <p>I have Created a database in mysql</p>
  
  <pre><code>mysql&gt; SELECT * FROM test456;
  +-----+-------+-------------------------+
  | _id | name  | image                   |
  +-----+-------+-------------------------+
  |   1 | Chris | /home/images/index.jpeg |
  +-----+-------+-------------------------+
  1 row in set (0.00 sec)
  </code></pre>
  
  <p>and <strong>My Express program is below</strong></p>
  
  <pre><code>var express = require('express')
    , http = require('http')
    , mysql = require('mysql'); // &lt;---- HERE
  
  var app = express();
  
  var connection = mysql.createConnection({
      host: 'localhost',
      user: 'root',
      password: "root",
      database: 'test123'
  });
  
  connection.connect(); // &lt;---- AND HERE
  
  // all environments
  app.set('port', process.env.PORT || 7005);
  
  
  app.get('/',function(request,response){
  connection.query('SELECT * FROM test456', function(err, rows, fields)
  
     {
              console.log('Connection result error '+err);
              console.log('no of records is '+rows.length);
                      response.writeHead(200, { 'Content-Type': 'application/json'});
              response.end(JSON.stringify(rows));
      });
  
  } );
  
  
  
  http.createServer(app).listen(app.get('port'), function(){
    console.log('Express server listening on port ' + app.get('port'));
  });
  </code></pre>
  
  <p><strong>Output::</strong></p>
  
  <pre><code>[{"_id":1,"name":"Chris","image":[47,104,111,109,101,47,105,109,97,103,101,115,47,105,110,100,101,120,46,106,112,101,103]}]
  </code></pre>
  
  <p>Clearly you can see that i am not able to generate the image url instead i am generating hexadecimal number ...... how to make the hexadecimal number to a url </p>
  
  <p>My research shows that i need to use base64 encoding 
  but how can i apply that here </p>
  
  <p>any ideas</p>