Error: Pool is not a constructor

I am trying to use node-red-contrib-odbc which requires the node-odbc node.
I am getting "TypeError: Pool is not a constructor" in this line: this.pool = new Pool();
I am pasting the contents from odbc.js for more context.

module.exports = function(RED) {

"use strict";

var mustache = require("mustache");

var Pool = require("odbc").Pool;

function connection(config) {

    RED.nodes.createNode(this, config); = "";

    if (config.driver!=""){ = + "DRIVER="+config.driver + ";"


    if (config.server!=""){ = + "SERVER="+config.server + ";"


    if (this.credentials.username!=""){ = + "USER="+ this.credentials.username + ";"


    if (this.credentials.password != ""){ = + "PASSWORD="+ this.credentials.password + ";"

    } = + config.other;

    this.pool = new Pool();

    var node = this;


What do I need to change here to make it work?
Sorry if this appears too trivial a question. Stating the obvious - total Node-red noob here.

What database are you trying to connect to ?

The odbc node is 4+ years old, it is likely that it won't function properly.

1 Like

Its an industrial automation software which has to be accessed over ODBC or OLEDB.
OLEDB needs access via COM, hence I wanted to avoid using in Node-Red as it would bring more complications.
Node-red is a great tool, but node maintenance is becoming an issue it seems.

I just felt that there was a minor detail in the ODBC node which could fix this issue. E.g. the Pool class needs a connection string I think, which is not visible in the line > this.pool = new Pool();

maintenance is becoming an issue

Insert any software.

I'm not an expert on the nuances of Node.js, but it could be that your "require" needs to use a different name. You have two uses of "Pool" :

versus :

You could either use a different var name, or possibly you need "new Pool.Pool()". (As I said, I'm no expert, but in other languages this would likely be flagged as an error.)

I tried that - same error. If I just update the .js file, is it enough to update the node, or do I need to 'compile' or do something else?

Hi @nrnoob,

the problem comes from the fact its package.json lists its dependency on the odbc module as this:

    "odbc": ">=0.6.11",

This means it will accepy anything newer than (or equal to) version 0.6.11. The odbc module is currently on version 2.2.2 - which means its had two major breaking version releases since the version the node was written for.

A quick fix would be to change the package.json file to install a version of odbc that is more likely to be compatible. For example, change ">=0.6.11" to "<1.0". Then run npm install from that directory.

Otherwise, it's a case of reading up on the odbc module and learning what changes it made in its 2.x branch and then updating the node's code to match.


Thanks. I will try out your suggestions.