title: Insert BLOB data in mariaDB using Node.js
body: <p>I want to insert blob data in mariaDB using node js,I am using HeidiSQL to interact with mariaDB.
  'users' table have two attributes 'user_email' and 'profile_photo'.</p>
  
  <p><strong>Similar Question</strong></p>
  
  <p>I found the following similar question but its not working in my case</p>
  
  <p><a href="https://stackoverflow.com/questions/25951251/nodejs-mysql-insert-blob">NodeJS mySQL Insert Blob</a></p>
  
  <p><strong>Here is my code:</strong></p>
  
  <pre><code>const inputfile = "C:\\Users\\Hammad Ali\\Desktop\\bloob\\routes\\CNN.jpg";
  var email = "xyz@gmail.com",
     photo = readImageFile(inputfile); 
  
  
     var query = "INSERT INTO `users` SET ?",
     values = {
       user_email: email,
       profile_photo: photo
     };
     pool.query(query, values,  function(err, res) {
    if (err) throw err;
    console.log("BLOB data inserted!"+res);
  });
  });
  
  function readImageFile(file) {
    // read binary data from a file:
    const bitmap = fs.readFileSync(file);
    const buf = new Buffer.from(bitmap);
    return buf;
  }
  </code></pre>
  
  <p><strong>Error</strong></p>
  
  <p><a href="https://i.stack.imgur.com/nvky1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nvky1.png" alt="enter image description here"></a></p>