1.0.3 • Published 2 years ago
@aux4/db-oracle v1.0.3
@aux4/db-oracle
JavaScript
Install
$ npm install @aux4/db-oracleExecute Query
const Database = require("@aux4/db-oracle");
const db = new Database({
  host: "localhost",
  user: "sysadmin",
  password: "******",
  service: "ORCL"
});
(async () => {
  await db.open();
  const { data } = await db.execute("select * from schema.table where id = :id", { id: 1 });
  console.log(JSON.stringify(data, null, 2));
  await db.close();
})();Query Stream
const Database = require("@aux4/db-oracle");
const db = new Database({
  host: "localhost",
  user: "sysadmin",
  password: "******",
  service: "ORCL"
});
const stream = await db.stream("select * from schema.table where id = :id", { id: 1 });
stream.on("data", row => {
console.log(JSON.stringify(row, null, 2));
});
stream.on("error", err => {
console.error(err.message);
});
stream.on("close", async () => {
await db.close();
});Command Line
Install
$ npm install --global @aux4/db
$ npm install --global @aux4/db-oracleUsage
Execute Query
$ db execute --host localhost --port 1521 --user sysadmin --service ORCL --query "select * from schema.table where id = :id" --id 1Stream Query
$ db stream --host localhost --port 1521 --user sysadmin --service ORCL --query "select * from schema.table where id = :id" --id 1Using @aux4/config
create config.yaml
config:
  dev:
    oracle:
      host: localhost
      port: 1521
      user: sysadmin
      password: "******"
      service: ORCL$ db execute --configFile config.yaml --config dev/oracle --query "select * from schema.table where id = :id" --id 1