Files
codeql/javascript/ql/test/library-tests/frameworks/SQL/mysql1a.js
2020-09-02 17:35:47 +01:00

25 lines
573 B
JavaScript

// Adapted from the documentation of https://github.com/mysqljs/mysql,
// which is licensed under the MIT license; see file mysqljs-License.
function importMySql() {
return require("mysql");
}
var connection = importMySql().createConnection({
host: 'localhost',
user: 'me',
password: 'secret',
database: 'my_db'
});
connection.connect();
connection.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
connection.end();
exports.connection = connection;