idb-connector

A Node.js DB2 driver for IBM i

MIT 47 个版本
安装
npm install idb-connector
yarn add idb-connector
pnpm add idb-connector
bun add idb-connector
README

Node.js iDB Connector for IBM i

The Node.js iDB Connector is an IBM i Node.js Db2 driver open source project from IBM

NPM

Node-API v3 Badge

Installation

    npm i idb-connector

NOTE This package only installs on IBM i systems.

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

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

Quick Example

Example 1: Fetching data using the exec() API

    const {dbconn, dbstmt} = require('idb-connector');

    const sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
    const connection = new dbconn();
    connection.conn('*LOCAL');
    const statement = new dbstmt(connection);

    statement.exec(sSql, (x) => {
      console.log(JSON.stringify(x));
      statement.close();
      connection.disconn();
      connection.close();
    });

Example 2: Fetching data using the fetchAll() API


    const {dbconn, dbstmt} = require('idb-connector');

    const sSql = 'SELECT STATE FROM QIWS.QCUSTCDT';
    const connection = new dbconn();
    connection.conn('*LOCAL');
    const statement = new dbstmt(connection);

    statement.prepare(sSql, () => {
      statement.execute(() => {
        statement.fetchAll((x) => {
          console.log(`Result is : ${JSON.stringify(x)}`);
          statement.close();
        });
      });
    });

Example 3: Call stored procedures

    const {dbconn, dbstmt} = require('idb-connector');

    const sql = 'CALL QXMLSERV.iPLUG512K(?,?,?,?)';
    const connection = new dbconn();
    connection.conn('*LOCAL');
    const statement = new dbstmt(connection);

    const ipc = '*NA';
    const ctl = '*here';
    const xmlIn = `<xmlservice><sh>system 'wrksbs'</sh></xmlservice>`;
    const xmlOut = '';

    statement.prepare(sql, () => {
      statement.bindParameters([ipc, ctl, xmlIn, xmlOut], () => {
        statement.execute((out) => {
          for (let i = 0; i < out.length; i += 1) {
            console.log(out[i]);
          }
          statement.close();
          connection.disconn();
          connection.close();
        });
      });
    });

API Reference

Db2 for i Access APIs

Change Log

View CHANGELOG.md file.

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@github.com:IBM/nodejs-idb-connector.git
    cd nodejs-idb-connector
    npm install --build-from-source

Build Dependencies

Note: sqlcli header files, GCC, and Python are required to compile the code.

    yum install sqlcli-devel
    yum group install 'Development tools' 
    yum install python2

License

MIT

Contributing

Please read the contribution guidelines.

版本列表
1.2.19-beta.0 2023-07-19
1.2.19 2024-02-06
1.2.18 2022-11-01
1.2.17 2022-10-31
1.2.16 2022-04-27
1.2.15 2021-12-20
1.2.14 2021-12-20
1.2.13 2021-06-07
1.2.12 2021-04-26
1.2.11 2021-04-22
1.2.10 2020-10-21
1.2.9 2020-05-25
1.2.8 2020-04-13
1.2.7 2020-03-23
1.2.6 2020-02-21
1.2.5 2020-01-22
1.2.4 2019-11-12
1.2.3 2019-10-15
1.2.2 2019-08-07
1.2.1 2019-07-05
1.2.0 2019-05-28
1.1.10 2019-04-08
1.1.9 2019-02-25
1.1.8 2019-01-25
1.1.7 2019-01-14
1.1.6 2018-12-27
1.1.5 2018-12-04
1.1.4 2018-10-22
1.1.3 2018-10-17
1.1.2 2018-08-24
1.1.1 2018-08-03
1.1.0 2018-08-01
1.0.13 2018-07-04
1.0.12 2018-06-21
1.0.11 2018-05-22
1.0.10 2018-05-02
1.0.9 2018-04-26
1.0.8 2018-04-26
1.0.7 2018-04-16
1.0.6 2018-03-12
1.0.5 2018-02-02
1.0.4 2018-02-02
1.0.3 2018-02-02
1.0.2 2018-01-29
1.0.1 2018-01-29
1.0.0 2018-01-26
0.0.1 2017-12-27