node-red-contrib-postgresql is a Node-RED contribution that provides a node for interacting with PostgreSQL databases. It is currently at version 0.15.4 and has a relatively steady release cadence, primarily focused on bug fixes, dependency updates, and minor enhancements. Key features include robust support for parameterized SQL queries (both numeric $1/$2 and emulated named $id parameters), efficient handling of large datasets through resultset splitting and backpressure (flow control), and flexible dynamic SQL query input via `msg.query`. It provides database responses in `msg.payload`, with additional metadata in `msg.pgsql`. The node integrates directly into the Node-RED flow editor, abstracting away direct `node-postgres` client management for most use cases, though advanced users can dynamically configure client settings via `msg.pgConfig` for specific scenarios.
npm install node-red-contrib-postgresqlVerified import paths — ran on the pinned version, not inferred.
Demonstrates preparing `msg.query` and `msg.params` in a Node-RED Function node for an upsert operation into a PostgreSQL database, typically followed by the `node-red-contrib-postgresql` node.
Prefer numeric parameterized queries (`$1`, `$2`, etc.) with `msg.params` for enhanced robustness and direct PostgreSQL compatibility, especially for critical applications.
For most scenarios, configure your PostgreSQL database connection using the dedicated configuration node within the Node-RED editor to benefit from connection pooling and optimized resource management.
Downstream nodes processing the output should be designed to handle both array and single-object payloads or explicitly check `msg.payload`'s type when the 'Split results' option is active.
Always use parameterized queries with `msg.params` or `msg.queryParameters` for any user-controlled input. This separates data from the query, preventing injection attacks.
Upgrade to `v0.15.3` or a newer version to benefit from the fix for `pg-cursor` exceptions and ensure better stability with large datasets.
Ensure that the PostgreSQL query node is connected to a properly configured and deployed PostgreSQL configuration node in your Node-RED flow.
Carefully review the SQL query for any syntax errors. If using Mustache templates for text values, ensure they are correctly quoted (e.g., `WHERE name = '{{{msg.name}}}'`). Prefer parameterized queries to avoid such issues and enhance security.Verify that your PostgreSQL database server is running and network accessible. Double-check the host IP address/hostname and port number in your PostgreSQL configuration node.
Confirm that the username and password configured in the PostgreSQL connection node are correct and that the user has appropriate database access privileges.
No dependency data recorded yet.