Node-RED & DB2 for i Connector

I know I said in my last article that was the end of my little project on the Raspberry Pi with Machine Learning talking to the IBM i.  Well since my last piece I have found how to correct a couple of the moans I had with Node-RED on the IBM i.

My last article can be found at https://powerwire.eu/raspberry-pi-and-machine-learning-2/ if you missed it.

As you may recall, I had intended to receive details of a photograph taken by the Raspberry Pi and then, using ActiveMQ as a delivery method, store those details on my IBM i using Node-RED and DB2 for i.

This idea failed misserably as I could not install the DB2 for i module in Node-RED. 

This article will show how I got around this issue with the DB2 for i module in Node-RED.

When I attempted to install the DB2 for i module, it failed with an error code of 127.  Nothing could be found on the web on how to resolve this problem.  Even trying the install on another Power server gave the same results.

As I was struggling with time, I used PostgreSQL to store the details, but being someone who loves a challenge, I had to find out why this failed and how to get around this problem. 

The Node-RED documentation for the db2-for-I node is very dated.  It hasn’t been touched for over two years https://flows.nodered.org/node/node-red-contrib-db2-for-i and my issue on the associated GitHub repository hasn’t had any response https://github.com/IBM/node-red-contrib-db2-for-i/issues

Looking into the coding of this node, it can be seen that it is only a front end for the node package idb-connector and this is where the problem existed.

The Node-RED flow needs the idb-connector to have any chance of working.  This has to be installed prior to the Node-RED db2 connector to work successfully.

The idb-connector repository on GitHub is very active and well supported.  It can be found at https://github.com/IBM/nodejs-idb-connector

The steps necessary to successfully use the Node-RED DB2 for i adapter are shown in the figure below.

And that resolved my problem.

Conclusion

To conclude, you must manually install the pre-req of idb-connector before you install the Node-RED package node-red-contrib-db2-for-i

You will then be able to use the Node-RED adapter to successfully access your DB2 for i database.

As the Node-RED adapter has the idb-connector listed as a dependency it should automatically be installed for you, but as both I and a fellow IBM i friend can contest this doesn’t happen.  If I get time, I’ll see if I can find out why.

All the examples I have written for this article, and previous ones, can be found on my open-source repository on GitHub, which can be found at https://github.com/formaserve/f_Learning

If you have any questions, either on this article, or anything else on the IBM i, use the comments below, or send me a message on twitter @AndyYouens

Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems with over 40 years IBM midrange experience. 

IBM Champion

Verified by MonsterInsights