@bdkinc/knex-ibmi 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,150 +1,133 @@
1
- [![npm version](http://img.shields.io/npm/v/knex-db2.svg)](https://npmjs.org/package/knex-db2)
2
- [![Build Status](https://travis-ci.org/henryjw/knex-db2.svg?branch=master)](https://travis-ci.org/henryjw/knex-db2)
3
- [![Known Vulnerabilities](https://snyk.io/test/npm/knex-db2/badge.svg)](https://snyk.io/test/npm/knex-db2)
4
- [![dependencies Status](https://david-dm.org/henryjw/knex-db2/status.svg)](https://david-dm.org/henryjw/knex-db2)
5
- [![devDependencies Status](https://david-dm.org/henryjw/knex-db2/dev-status.svg)](https://david-dm.org/henryjw/knex-db2?type=dev)
6
-
7
- **Disclaimer: this library is in early stages of development. Use at your own risk. Please submit an issue for any bugs encounter or any questions you have.**
8
-
9
- ## Description
10
-
11
- This is an external dialect for [knex](https://github.com/tgriesser/knex). This library is only tested on IBMi. Here are the IBM OSS Docs https://ibmi-oss-docs.readthedocs.io/en/latest/odbc/README.html
12
-
13
- ## Limitations
14
-
15
- Currently this dialect has limited functionality compared to the Knex built-in dialects. Below are some of the limitations:
16
-
17
- - No transaction support
18
- - No streaming support
19
- - Possibly other missing functionality
20
-
21
- ## Supported functionality
22
-
23
- - Query building
24
- - Query execution (see [Limitations](#Limitations))
25
-
26
- ## Installing
27
-
28
- `npm install https://github.com/bdkinc/knex-ibmi`
29
-
30
- Requires Node v14 or higher.
31
-
32
- ## Dependencies
33
-
34
- `npm install odbc` see [ODBC dependencies](#odbc-dependencies) if you run into any issues
35
-
36
- `npm install knex`
37
-
38
- ## Usage
39
- This library is written in typescript and compiled to both commonjs and esm.
40
-
41
- ```javascript
42
- const Knex = require("knex");
43
- const { Db2Dialect } = require("knex-ibmi");
44
-
45
- const knex = Knex({
46
- client: Db2Dialect,
47
- connection: {
48
- host: "localhost",
49
- database: "knextest",
50
- port: 50000,
51
- user: "db2inst1",
52
- password: "db2inst1-pwd",
53
- driver: "IBM i Access ODBC Driver",
54
- connectionStringParams: {
55
- ALLOWPROCCALLS: 1,
56
- CMT: 0,
57
- },
58
- },
59
- pool: {
60
- min: 2,
61
- max: 10,
62
- },
63
- });
64
-
65
- const query = knex.select("*").from("table1").where("x", "y");
66
-
67
- query
68
- .then((result) => console.log(result))
69
- .catch((err) => console.error(err))
70
- .finally(() => process.exit());
71
- ```
72
-
73
- or as ESM
74
-
75
- ```javascript
76
- import knex from "knex";
77
- import { Db2Dialect } from "knex-ibmi";
78
-
79
- const knex = Knex({
80
- client: Db2Dialect,
81
- connection: {
82
- host: "localhost",
83
- database: "knextest",
84
- port: 50000,
85
- user: "db2inst1",
86
- password: "db2inst1-pwd",
87
- driver: "IBM i Access ODBC Driver",
88
- connectionStringParams: {
89
- ALLOWPROCCALLS: 1,
90
- CMT: 0,
91
- },
92
- },
93
- pool: {
94
- min: 2,
95
- max: 10,
96
- },
97
- });
98
-
99
- const query = knex.select("*").from("table1").where("x", "y");
100
-
101
- query
102
- .then((result) => console.log(result))
103
- .catch((err) => console.error(err))
104
- .finally(() => process.exit());
105
- ```
106
-
107
- ## ODBC dependencies
108
-
109
- - make: `sudo apt install make`
110
- - g++: `sudo apt install g++`
111
- - unix odbc: `sudo apt-get install unixodbc unixodbc-dev`
112
-
113
- ## Configuring your driver
114
-
115
- If you don't know the name of your installed driver, then look in look in `odbcinst.ini`. You can find the full path of the file by running `odbcinst -j`.
116
- There you should see an entry like the one below:
117
-
118
- ```
119
- [IBM i Access ODBC Driver 64-bit] <= driver name enclosed in square brackets
120
- Description=IBM i Access for Linux 64-bit ODBC Driver
121
- Driver=/opt/ibm/iaccess/lib64/libcwbodbc.so
122
- Setup=/opt/ibm/iaccess/lib64/libcwbodbcs.so
123
- Threading=0
124
- DontDLClose=1
125
- UsageCount=1
126
- ```
127
-
128
- If that still doesn't work, then unixodbc is probably looking for the config files in the wrong directory. A common case is that the configs are in `/etc` but your system expects them to be somewhere else. In such case, override the path unixodbc looks in via the `ODBCSYSINI` and `ODBCINI` environment variables.
129
- E.g., `ODBCINI=/etc ODBCSYSINI=/etc`.
130
-
131
- ## Installing default driver
132
-
133
- ### Download driver
134
-
135
- https://github.com/ibmdb/node-ibm_db#-download-clidriver-based-on-your-platform--architecture-from-the-below-ibm-hosted-url
136
-
137
- ### Install driver
138
-
139
- - Extract downloaded file. This will create a `clidriver` folder with the driver contents
140
- - Copy this folder to wherever your system keeps drivers. If you're not sure where to put it, just copy it to `/opt/ibm`.
141
- - Add the configuration your `/etc/odbcinst.ini` file. Below is what the contents of the file should look like if your odbc path is `/opt`
142
-
143
- ```
144
- [IBM Cli Driver]
145
- Description=IBM CLI Driver for Linux 64-bit
146
- Driver=/opt/ibm/clidriver/lib/libdb2.soSetup=libdb2.so.1
147
- hreading=0
148
- DontDLClose=1
149
- UsageCount=1
150
- ```
1
+ [![npm version](http://img.shields.io/npm/v/knex-db2.svg)](https://npmjs.org/package/@bdkinc/knex-ibmi)
2
+
3
+ **Disclaimer: this library is in early stages of development. Please submit an issue for any bugs encounter or any questions you have.**
4
+
5
+ ## Description
6
+
7
+ This is an external dialect for [knex](https://github.com/tgriesser/knex). This library uses the ODBC driver and is only tested on IBMi. Here are the IBM OSS Docs https://ibmi-oss-docs.readthedocs.io/en/latest/odbc/README.html
8
+
9
+ ## Supported functionality
10
+
11
+ - Query building
12
+ - Query execution (see [Limitations](#Limitations))
13
+ - Transactions
14
+
15
+ ## Limitations
16
+
17
+ Currently, this dialect has limited functionality compared to the Knex built-in dialects. Below are some of the limitations:
18
+
19
+ - No streaming support
20
+ - Possibly other missing functionality
21
+ - Uses a pool for all connections
22
+
23
+ ## Installing
24
+
25
+ `npm install @bdkinc/knex-ibmi`
26
+
27
+ Requires Node v14 or higher.
28
+
29
+ ## Dependencies
30
+
31
+ `npm install odbc` see [IBM ODBC Docs for dependencies](https://ibmi-oss-docs.readthedocs.io/en/latest/odbc/README.html) if you run into any issues
32
+
33
+ `npm install knex`
34
+
35
+ ## Usage
36
+
37
+ This library is written in typescript and compiled to both commonjs and esm.
38
+
39
+ ```javascript
40
+ const knex = require("knex");
41
+ const { Db2Dialect } = require("knex-ibmi");
42
+
43
+ const db = knex({
44
+ client: Db2Dialect,
45
+ connection: {
46
+ host: "localhost",
47
+ database: "knextest",
48
+ port: 50000,
49
+ user: "<user>",
50
+ password: "<password>",
51
+ driver: "IBM i Access ODBC Driver",
52
+ connectionStringParams: {
53
+ ALLOWPROCCALLS: 1,
54
+ CMT: 0,
55
+ },
56
+ },
57
+ pool: {
58
+ min: 2,
59
+ max: 10,
60
+ },
61
+ });
62
+
63
+ const query = db.select("*").from("table").where({ foo: "bar" });
64
+
65
+ query
66
+ .then((result) => console.log(result))
67
+ .catch((err) => console.error(err))
68
+ .finally(() => process.exit());
69
+ ```
70
+
71
+ or as ESM
72
+
73
+ ```javascript
74
+ import knex from "knex";
75
+ import { Db2Dialect } from "knex-ibmi";
76
+
77
+ const db = knex({
78
+ client: Db2Dialect,
79
+ connection: {
80
+ host: "localhost",
81
+ database: "knextest",
82
+ port: 50000,
83
+ user: "<user>",
84
+ password: "<password>",
85
+ driver: "IBM i Access ODBC Driver",
86
+ connectionStringParams: {
87
+ ALLOWPROCCALLS: 1,
88
+ CMT: 0,
89
+ },
90
+ },
91
+ pool: {
92
+ min: 2,
93
+ max: 10,
94
+ },
95
+ });
96
+
97
+ try {
98
+ const data = await db.select("*").from("table").where({ foo: "bar" });
99
+ console.log(data);
100
+ } catch (err) {
101
+ throw new Error(err);
102
+ } finally {
103
+ process.exit();
104
+ }
105
+ ```
106
+
107
+ ## Configuring your driver
108
+
109
+ If you don't know the name of your installed driver, then look in look in `odbcinst.ini`. You can find the full path of the file by running `odbcinst -j`.
110
+ There you should see an entry like the one below:
111
+
112
+ ```
113
+ [IBM i Access ODBC Driver] <== driver name in square brackets
114
+ Description=IBM i Access for Linux ODBC Driver
115
+ Driver=/opt/ibm/iaccess/lib/libcwbodbc.so
116
+ Setup=/opt/ibm/iaccess/lib/libcwbodbcs.so
117
+ Driver64=/opt/ibm/iaccess/lib64/libcwbodbc.so
118
+ Setup64=/opt/ibm/iaccess/lib64/libcwbodbcs.so
119
+ Threading=0
120
+ DontDLClose=1
121
+ UsageCount=1
122
+
123
+ [IBM i Access ODBC Driver 64-bit]
124
+ Description=IBM i Access for Linux 64-bit ODBC Driver
125
+ Driver=/opt/ibm/iaccess/lib64/libcwbodbc.so
126
+ Setup=/opt/ibm/iaccess/lib64/libcwbodbcs.so
127
+ Threading=0
128
+ DontDLClose=1
129
+ UsageCount=1
130
+ ```
131
+
132
+ If that still doesn't work, then unixodbc is probably looking for the config files in the wrong directory. A common case is that the configs are in `/etc` but your system expects them to be somewhere else. In such case, override the path unixodbc looks in via the `ODBCSYSINI` and `ODBCINI` environment variables.
133
+ E.g., `ODBCINI=/etc ODBCSYSINI=/etc`.