Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

idb-connector

Package Overview
Dependencies
Maintainers
3
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idb-connector

A Node.js DB2 driver for IBM i

  • 1.1.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
185
decreased by-15.53%
Maintainers
3
Weekly downloads
 
Created
Source

Node.js iDB Connector

The Node.js iDB Connector is a Node.js DB2 driver open source project from IBM.

Installation

npm i idb-connector

Then you can require in your code, as shown below.

    const db = require('idb-connector');

Quick Example

Example 1: Fectching data using the exec() API

    const db = require('idb-connector');
    const sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
    const dbconn = new db.dbconn();
    dbconn.conn("*LOCAL");
    const stmt = new db.dbstmt(dbconn);

    stmt.exec(sSql, (x) => {
      console.log("%s", JSON.stringify(x));
      stmt.close();
      dbconn.disconn();
      dbconn.close();
    });

Example 2: Fectching data using the fetchAll() API

    const db = require('idb-connector');
    const sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
    const dbconn = new db.dbconn();
    dbconn.conn("*LOCAL");
    const stmt = new db.dbstmt(dbconn);

    stmt.prepare(sSql, () => {
      stmt.execute(() => {
        stmt.fetchAll((x) => { 
          console.log("%s", JSON.stringify(x));
          stmt.close();
        });
      });
    });

Example 3: Call stored procedures

    const db = require('idb-connector');
    const sql = "CALL QXMLSERV.iPLUG512K(?,?,?,?)";
    const dbconn = new db.dbconn();
    dbconn.conn("*LOCAL");
    const stmt = new db.dbstmt(dbconn);

    const ipc = "*NA";
    const ctl = "*here";
    const xmlIn = "<xmlservice><sh>system 'wrksbs'</sh></xmlservice>";
    const xmlOut = "";
    
    stmt.prepare(sql, () => {
      stmt.bindParam([
        [ipc, db.SQL_PARAM_INPUT, db.BIND_STRING],
        [ctl, db.SQL_PARAM_INPUT, db.BIND_STRING],
        [xmlIn, db.SQL_PARAM_INPUT, db.BIND_CLOB],
        [xmlOut, db.SQL_PARAM_OUTPUT, db.BIND_CLOB]
      ], () => {
        stmt.execute((out) => { // 'out' is an array of output params
          for(let i = 0; i < out.length; i++)
            console.log(out[i]);
          stmt.close();
          dbconn.disconn();
          dbconn.close();
        });
      });
    });

API Reference

DeveloperWorks

Build

Note that building isn't necessary for end users and is more for developers looking to compile the native Node.js extensions (C code).

    git clone git@bitbucket.org:litmis/nodejs-idb-connector.git
    cd nodejs-idb-connector
    npm install --build-from-source

Note: Gcc and python are required to compile the code.

License

MIT. View LICENSE file.

Keywords

FAQs

Package last updated on 04 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc