# @topcs/node-red-contrib-postgres COPY mode

**URL:** <https://discourse.nodered.org/t/topcs-node-red-contrib-postgres-copy-mode/101322>\
**Category:** General\
**Tags:** database\
**Created:** [19 June 2026 14:08 UTC](https://discourse.nodered.org/t/topcs-node-red-contrib-postgres-copy-mode/101322 "2026-06-19T14:08:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcamire](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@mcamire](https://discourse.nodered.org/u/mcamire)\
**Post date:** [19 June 2026 14:08 UTC](https://discourse.nodered.org/t/topcs-node-red-contrib-postgres-copy-mode/101322/1 "2026-06-19T14:08:39Z")

</div>

Hi, I have been trying to use the PostgresNode to query a timescaleDB database with a COPY statement. I am using the PostgresNode from @topcs/node-red-contrib-postgres module since it's the only module I could find that supports COPY statement.

I use Node RED version 4.1.10 and Node.js v20.20.2.

Ideally the query statement I'd use would be like this:

```auto
COPY ( SELECT * FROM motors_data WHERE motor_id = 'M001' 
AND time BETWEEN '2026-06-17T10:00:45.799Z'
AND '2026-06-17T16:00:45.799Z')
TO STDOUT WITH (FORMAT csv, HEADER true, DELIMITER ',');

```

Where the motor\_id and the times are received in msg.payload and the query statement is format in a function node.

I have been testing with simpler statement directy in the PostgresNode. When I try this:

 ![Capture d’écran 2026-06-19 095520](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/8/78fa0fb4145a404538f6cf1ae996a12a09ec74a3.png)

My Node RED instance crashes and I get this error in my terminal:

```auto
Jun 13:53:27 - [info] Started flows

19 Jun 13:53:31 - [info] [PostgresNode:f2eeb63b7b85be83] Connected to database

[red] Uncaught Exception:

19 Jun 13:53:31 - [error] TypeError: activeQuery.handleCopyData is not a function

    at Client._handleCopyData (/data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg/lib/client.js:517:17)

    at Connection.emit (node:events:524:28)

    at /data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg/lib/connection.js:115:12

    at Parser.parse (/data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg-protocol/dist/parser.js:38:17)

    at Socket.<anonymous> (/data/node_modules/@topcs/node-red-contrib-postgres/node_modules/pg-protocol/dist/index.js:11:42)

    at Socket.emit (node:events:524:28)

    at addChunk (node:internal/streams/readable:561:12)

    at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)

    at Readable.push (node:internal/streams/readable:392:5)

    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)

```

Also, since I didn't much documentation on the COPY mode from this node I don't know if this error is abnormal or if I am not using the right way. Either way, I hope someone will help solve this issue.

Thank you!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 June 2026 14:27 UTC](https://discourse.nodered.org/t/topcs-node-red-contrib-postgres-copy-mode/101322/2 "2026-06-19T14:27:11Z")

</div>

Welcome to the forum. Since the node seems to be under active development I suggesting asking on the node's GitHub issues page. I see it has just been updated so check you are on the latest version.

A node should never crash node red like that, even if you give it bad data, so that needs to be fixed.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [17 September 2026 14:27 UTC](https://discourse.nodered.org/t/topcs-node-red-contrib-postgres-copy-mode/101322/3 "2026-09-17T14:27:17Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
