Database-js Wrapper for ADODB
Database-js-adodb is a wrapper around the node-adodb package by nuintun. It is intended to be used with the database-js package. However it can also be used in stand alone mode. The only reason to do that would be to use Promises.
Because it depends on node-adodb, database-js-adodb will only work on Windows, or more correctly on operating systems which can do ADO access from the Windows Script cscript.
var adodb = require('database-js-adodb');
(async () => {
let connection, rows;
connection = mysql.open({
Database: 'C:\\Users\\me\\Desktop\\access_db.mdb'
});
try {
rows = await connection.query("SELECT * FROM tablea WHERE user_name = 'not_so_secret_user'");
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();
var Database = require('database-js2');
(async () => {
let connection, statement, rows;
connection = new Database('database-js-adodb:///C:\\Users\\me\\Desktop\\access_db.mdb');
try {
statement = await connection.prepareStatement("SELECT * FROM tablea WHERE user_name = ?");
rows = await statement.query('not_so_secret_user');
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();
var Database = require('database-js2');
(async () => {
let connection, statement, rows;
connection = new Database('database-js-adodb:///C:\\Users\\me\\Desktop\\excel_file.xls?Extended Properties='Excel 8.0;HDR=Yes;IMEX=1';');
try {
statement = await connection.prepareStatement("SELECT * FROM [Sheet1$A1:C52] WHERE user_name = ?");
rows = await statement.query('not_so_secret_user');
console.log(rows);
} catch (error) {
console.log(error);
} finally {
await connection.close();
}
})();