ER_PARSE_ERROR on sql file

I'm trying to execute sql queries from a file in nodejs.

This is the (summarized) code:

var fs = require("fs");
var mysql = require("mysql");

fs.readFile("path/to/my.sql", function(error, query) {
    mysql.connect(configuration, function(error, connection) {
        connection.query(query.toString(), callback); // this doesn't work
    }
}

Upon execution, following error is passed to my callback function:

{"code":"ER_PARSE_ERROR","index":0}

I have verified that:

  • I can connect to the mysql host
  • I can execute inline queries
  • I can execute the file in mysql workbench
  • I can open the file in node.js and log it to the console