Last few weeks I had been trying to connect oracle db from my nodejs code. What I found so far are 2 main libraries such as https://github.com/mariano/node-db-oracle which is out of date (last update was year ago) and second one is https://github.com/nearinfinity/node-oracle which is really up to date, however I didn't manage to connect oracle with any of those modules.
Mayor issue that npm install oracle //pr db-oracle fails due to
../src/connection.h:10:18: fatal error: occi.h: No such file or directory
I tried to clone the code and perform local install and then copy entire module under my project, install wen well, but when I place module under my project I run into this error
module.js:340
throw err;
^
Error: Cannot find module './build/Release/oracle_bindings'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/www/node-test/node_modules/db-oracle/db-oracle.js:18:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
I had been follow installation procedure for both drivers and had been setup variables like this (/var/environment)
OCI_HOME=/opt/instantclient_12_1
OCI_VERSION=12
OCI_INCLUDE_DIR=/opt/instantclient_12_1/sdk/include
OCI_LIB_DIR=/opt/instantclient_12_1
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client/lib
I used ubuntu 12.04, and node version is v0.10.18 here is my sample nodejs test file:
var oracle = require('oracle');
new oracle.Database({
hostname: 'myserver.com',
port: 1521,
user: 'myuser',
password: 'mypass',
database: 'XE'
}).connect(function(error) {
if (error) {
return console.log("CONNECTION ERROR: " + error);
}
this.query("select * FROM `store`").execute(function(error, rows) {
if (error) {
return console.log('ERROR: ' + error);
}
console.log(rows.length + ' ROWS');
});
});
any additional hint would be nice. I tried noradle (https://github.com/kaven276/noradle) that one seems to be to heavy for my purpose.