A Node-RED node for reading and writing to Microsoft Access databases on Windows. Supports Access 97 and newer (.mdb) as well as the modern .accdb format.
Communication goes through the Windows Scripting Host, which means this accessdb will not function on Linux or macOS.
This package works in any modern Node.js environment on Windows. This package is a Node-RED adaptation of ACCESSdb, a client-side JavaScript library written by Joshua Faulkenberry in 2009.
Joshua Faulkenberry original project ACCESSdb on SourceForge
Node-RED must be running on a Windows machine that has Microsoft ACE OLEDB 12.0 or higher installed.
If it is not already present, download Access Database Engine before using these nodes.
From your Node-RED user directory, run:
npm install ANDOR-Automation-AB/node-red-contrib-accessdbAfter restarting Node-RED you will find one new node in the palette under the storage category: accessdb. A second node, accessdb-config, is a configuration node and does not appear in the palette directly — it is created and managed through the configuration dialog of the accessdb node.
The accessdb-config node holds the connection details for a specific database file. Multiple accessdb nodes can share the same configuration node, meaning you only need to define the path and credentials for a given database once.
The Provider field selects which Access version your database file was created with. Choose Access 2000 and newer for .mdb files created in Access 2000 through 2003 and all .accdb files — this is the default. Choose Access 97 for older .mdb files created in Access 97. The correct underlying OLEDB driver is selected automatically based on this choice, and no additional installation is required for either option.
The Database file field accepts either an absolute path such as C:\Data\MyDatabase.mdb or a path relative to the Node-RED user directory, for example my.mdb if the file sits directly in .node-red. Both forward slashes and backslashes are accepted and normalised automatically. The resolved path must be accessible to the Windows user account that runs the Node-RED process.
Checking Create if missing will create an empty Access database at the given path the first time Node-RED starts with that configuration, provided the file does not already exist. The database is created using ADOX via a temporary VBScript, and a confirmation is written to the Node-RED log. If creation fails the error is logged and Node-RED continues without the database.
The User and Password fields are optional. Most Access databases created without user-level security have no username or password, and these fields should be left empty in that case. When a password is provided it is stored in Node-RED's encrypted credentials store rather than in the flow configuration, so it is not exposed in the exported flow JSON.
The Persist security checkbox sets Persist Security Info=True in the connection string. This is rarely needed and should remain unchecked unless the database or driver specifically requires it.
The Workgroup file field accepts a full path to an .mdw workgroup file. Workgroup files are used in older Access databases that have user-level security enabled. This feature has been deprecated by Microsoft since Access 2007 and most modern databases do not need it.
The ADODB connection object is created once when the configuration node initialises and is shared across all accessdb nodes that reference it. The node-adodb library manages the actual connection lifecycle internally, opening and closing native connections per operation through the Windows Scripting Host.
This node executes any SQL statement against a Microsoft Access database. Write the SQL directly in the node's SQL field, or supply it at runtime via msg.query, which takes priority over whatever is configured in the node.
The node automatically detects whether the statement is a SELECT query by checking if the SQL begins with the word SELECT. If it is a SELECT, the node calls the underlying query method and places the result set on msg.payload as an array of plain JavaScript objects. Each object represents one row, and each key corresponds to a column name exactly as it appears in the database schema. If the query returns no rows, msg.payload is an empty array.
For all other statements — INSERT, UPDATE, DELETE, or any DDL statement — the node calls the execute method instead and sets msg.payload to { success: true } when the statement completes without error.
While the statement is running the node's status indicator turns blue. On success it turns green and shows either the row count (for SELECT) or "done" (for other statements). On error it turns red and the error is forwarded to Node-RED's standard error handling mechanism, meaning it can be caught downstream with a catch node.
A few examples of what you can write in the SQL field:
SELECT * FROM Customers WHERE Country = 'Sweden'INSERT INTO Orders (CustomerID, Product, Quantity) VALUES (42, 'Widget', 10)UPDATE Products SET Price = 99.50 WHERE ProductID = 7DELETE FROM Sessions WHERE Expired = TrueWhen building SQL dynamically in an upstream function node, place the finished statement on msg.query rather than msg.payload, and wire that function node into the accessdb node. Be careful to validate and sanitise any values that originate from user input before interpolating them into a SQL string, as the node executes whatever SQL it receives without additional escaping.
Errors are propagated through Node-RED's standard done(err) mechanism. They appear in the debug panel and can be intercepted by wiring a catch node to the accessdb node. The caught message will have msg.error populated with the error details from the OLEDB driver or from the node's own validation.
Common causes of errors include an incorrect path to the database file, the ACE OLEDB provider not being installed or being of the wrong bitness relative to Node.js, the Node-RED process not having read or write permission to the database file, the database being open exclusively in another application such as Microsoft Access itself, or a malformed SQL statement. The error message text comes directly from the OLEDB driver and is usually descriptive enough to identify the cause.