All Projects → IBM → nodejs-idb-pconnector

IBM / nodejs-idb-pconnector

Licence: MIT License
Promise-based DB2 Connector for IBM i

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nodejs-idb-pconnector

ILEastic
Embedded application server for ILE on IBM i
Stars: ✭ 31 (+40.91%)
Mutual labels:  ibmi, ibmioss
ILEditor
IBM i development environment (IDE)
Stars: ✭ 83 (+277.27%)
Mutual labels:  ibmi, ibmioss
nodejs-idb-connector
A JavaScript (Node.js) library for communicating with Db2 for IBM i, with support for queries, procedures, and much more. Uses traditional callback-style syntax
Stars: ✭ 35 (+59.09%)
Mutual labels:  db2, ibmi
ublu
Ublu Midrange and Mainframe Life Cycle Extension Language
Stars: ✭ 13 (-40.91%)
Mutual labels:  ibmi, ibmioss
IBMi-Book
"Learning IBM i as a Web Developer", my subpar eBook for learning the basics of IBM i, RPGLE, Control Language, and more from the eyes of a web developer.
Stars: ✭ 31 (+40.91%)
Mutual labels:  ibmi, ibmioss
Connectors
Connectors simplify connecting to standalone and CloudFoundry services
Stars: ✭ 28 (+27.27%)
Mutual labels:  db2
banking-digitalization-using-hybrid-cloud-with-mainframes
The following journey will introduce the available Banking APIs published on IBM Cloud with logical business programs running on the IBM Z Mainframe through a simulated retail bank called MPLbank.
Stars: ✭ 21 (-4.55%)
Mutual labels:  db2
slack-chatbot-database-watson
Code for the solution tutorial "Build a database-driven Slackbot" (chatbot) with a custom extension in IBM Watson Assistant
Stars: ✭ 23 (+4.55%)
Mutual labels:  db2
ibmi-oss-docs
IBM i Open Source Documentation
Stars: ✭ 40 (+81.82%)
Mutual labels:  ibmi
Addax
Addax is an open source universal ETL tool that supports most of those RDBMS and NoSQLs on the planet, helping you transfer data from any one place to another.
Stars: ✭ 615 (+2695.45%)
Mutual labels:  db2
Notepad-RPG
RPG Free-Format & CL syntax for Nodepad++
Stars: ✭ 28 (+27.27%)
Mutual labels:  ibmi
IBMiCmd
x86 Notepad++ plugin for IBM i development
Stars: ✭ 15 (-31.82%)
Mutual labels:  ibmi
db2-docker
Docker image to run DB2 LUW
Stars: ✭ 37 (+68.18%)
Mutual labels:  db2
DBFilesClient.NET
Deprecated: See DBClientFiles.NET
Stars: ✭ 14 (-36.36%)
Mutual labels:  db2
db2-samples
Db2 application code, configuration samples, and other examples
Stars: ✭ 56 (+154.55%)
Mutual labels:  db2
ServiceCommander-IBMi
Service Commander for IBM i
Stars: ✭ 29 (+31.82%)
Mutual labels:  ibmi
vscode-ibmi-languages
Syntax highlighting for IBM i languages such as RPG, CL, DDS, MI, and RPGLE fixed/free.
Stars: ✭ 28 (+27.27%)
Mutual labels:  ibmi
default-gateway
Get the default network gateway, cross-platform.
Stars: ✭ 77 (+250%)
Mutual labels:  ibmi
casc
CASC extractor for World of Warcraft data
Stars: ✭ 15 (-31.82%)
Mutual labels:  db2
github-traffic-stats
Manage and automatically collect Github traffic statistics for repositories
Stars: ✭ 30 (+36.36%)
Mutual labels:  db2

npm ryver-chat ryver-signup docs

idb-pconnector - Promise-based DB2 Connector for IBM i

Project Status: (production ready as a "technology preview")

Objective: provide a promise-based database connector for DB2 on IBM i.

This project is a promise-based wrapper over the idb-connector project that enables the use of modern JavaScript's async/await syntax.

Connection Pooling is supported by using the DBPool class.

The DBPool class includes integrated aggregates (runSql and prepareExecute) to simplify your code.

Table of Contents

Install

npm install idb-pconnector

NOTE

This package only installs on IBM i systems.

Examples

exec

Using exec method to run a select statement and return the result set:

const { Connection, Statement, } = require('idb-pconnector');

async function execExample() {
  const connection = new Connection({ url: '*LOCAL' });
  const statement = new Statement(connection);

  const results = await statement.exec('SELECT * FROM QIWS.QCUSTCDT');

  console.log(`results:\n ${JSON.stringify(results)}`);
}

execExample().catch((error) => {
  console.error(error);
});

prepare bind execute

Using prepare, bind, and execute methods to insert data:

insert example

const {
  Connection, Statement, IN, NUMERIC, CHAR,
} = require('idb-pconnector');

async function pbeExample() {
  const connection = new Connection({ url: '*LOCAL' });
  const statement = new Statement(connection);
  const sql = 'INSERT INTO US_STATES(id, name, abbr, region) VALUES (?,?,?,?)';

  await statement.prepare(sql);
  await statement.bindParameters([1, 'Alabama', 'AL' ,'south']);
  await statement.execute();
}

pbeExample().catch((error) => {
  console.error(error);
});

select example

const {
  Connection, Statement, IN, CHAR,
} = require('idb-pconnector');

async function pbeExample() {
  const connection = new Connection({ url: '*LOCAL' });
  const statement = new Statement(connection);
  const sql = 'SELECT * FROM QIWS.QCUSTCDT WHERE CITY = ? AND STATE = ?';

  await statement.prepare(sql);
  await statement.bindParameters(['Dallas','TX']);
  await statement.execute();
  
  let resultSet = await statement.fetchAll();
  
  console.log(resultSet) // array with response
}

pbeExample().catch((error) => {
  console.error(error);
});

DBPool

Using DBPool to return a connection then call a stored procedure:

const { DBPool } = require('idb-pconnector');

async function poolExample() {
  const pool = new DBPool();

  const connection = pool.attach();

  const statement = connection.getStatement();

  const sql = `CALL QSYS2.SET_PASE_SHELL_INFO('*CURRENT', '/QOpenSys/pkgs/bin/bash')`

  await statement.prepare(sql);
  await statement.execute();

  if (results) {
    console.log(`results:\n ${JSON.stringify(results)}`);
  }
  await pool.detach(connection);
}

poolExample().catch((error) => {
  console.error(error);
});

prepareExecute

Using prepareExecute method to insert data:

const { DBPool } = require('idb-pconnector');

async function prepareExecuteExample() {
  /*
   * Prepare and execute an SQL statement.
   * Params are passed as an array values.
   * The order of the params indexed in the array
   * should map to the order of the parameter markers
   */
  const pool = new DBPool();

  const sql = 'INSERT INTO QIWS.QCUSTCDT VALUES (?,?,?,?,?,?,?,?,?,?,?) with NONE';

  const params = [4949, 'Johnson', 'T J', '452 Broadway', 'MSP', 'MN',
    9810, 2000, 1, 250, 0.00];

  await pool.prepareExecute(sql, params);
}

prepareExecuteExample().catch((error) => {
  console.error(error);
});

runSql

Using runSql method to directly execute a select statement:

NOTE

This method will not work with stored procedures use prepareExecute() instead.

const { DBPool } = require('idb-pconnector');

async function runSqlExample() {
  /*
   * Directly execute a statement by providing the SQL to the runSql() function.
   */
  const pool = new DBPool();

  const results = await pool.runSql('SELECT * FROM QIWS.QCUSTCDT');

  if (results) {
    console.log(`results:\n ${JSON.stringify(results)}`);
  }
}

runSqlExample().catch((error) => {
  console.error(error);
});

setLibraryList

Change to system naming and set the library list (using CHGLIBL) of the connection.

const { Connection } = require('idb-pconnector');

async function setLibListExample() {
  const connection = new Connection({ url: '*LOCAL' });

  await connection.setLibraryList(['QIWS', 'QXMLSERV']);

  const statement = connection.getStatement();
  const results = await statement.exec('SELECT * FROM QCUSTCDT');
  console.log(`results:\n ${JSON.stringify(results)}`);
  await statement.close();
}

setLibListExample().catch((error) => {
  console.error(error);
});

Documentation

Please read the docs.

License

MIT

Contributing

Please read the contribution guidelines.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].