I have a part of code that works fine - it executes a query against a database and print out all rows (line 9 bellow) . However I want to return back results to outside of function so that can parse results further etc.
function execute_query() {
connection.execute({
sqlText: 'show databases',
complete: function(err, stmt, rows) {
if (err) {
console.error('Failed to execute statement due to the following error: ' + err.message);
} else {
for (row in rows)
// Line 9: console.log(JSON.stringify(rows, null, 2));
}
},
});
}
console.log(execute_query());
How to achieve that goal within a snippet above?