Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diagnostic-channel-publisher to support "pg-copy-streams" #79

Closed
cons0l3 opened this issue Jun 24, 2020 · 1 comment
Closed

diagnostic-channel-publisher to support "pg-copy-streams" #79

cons0l3 opened this issue Jun 24, 2020 · 1 comment

Comments

@cons0l3
Copy link

cons0l3 commented Jun 24, 2020

When executing a pg_copy_stream:

        const pool = new Pool(config.database_config);
        const copyFrom = require('pg-copy-streams').from;
        const { Readable } = require('stream');
        const createCsvWriter = require('csv-writer').createArrayCsvStringifier
        [...]
        var target = db.query(copyFrom(`COPY temptable (a,b,c) FROM STDIN DELIMITER ';' CSV HEADER':''}`));
        var source = Readable.from(await csvWriter.stringifyRecords(table_data));
        source.pipe(target);

The target variable is not of type Promise it is of type CopyStreamQuery extending Writeable. This of course ends in the error:

TypeError: queryResult.then is not a function
    at Client.query (D:\home\site\wwwroot\node_modules\diagnostic-channel-publishers\dist\src\pg.pub.js:245:18)

versions:

    "applicationinsights": "^1.7.5",
    "pg": "^8.2.1",
    "csv-writer": "^1.6.0",
    "pg-copy-streams": "^5.1.0"

"applicationinsights" pull dependency to:

        "diagnostic-channel": "0.2.0",
        "diagnostic-channel-publishers": "^0.3.4"
@markwolff
Copy link

This seems like a dupe of #67. I'll look into this today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants