Friday 2 June 2017

NodeJs DataPumps with PostgreSQL: Process Hangs

Hi I started learning node.js three days ago and i have been trying to use datapumps. So far I am running node js with Express and the problem is that my process function never runs. I see this console.log("Ready To Pump"); in the logs so I am able to tell that the function is called. However it seems like the process hangs. (not sure). The process function is not called because console.log("We are in the Process"); part of the code does not show in the logs. Where have i gone wrong here. I also know my connection string works because i have onother function that uses the same query and logs the data to the console. I intend to transfer data from one postgre database to another. And certainly i cant do that if my process function is never called. I do not get any errors in the console either. I believe it hangs because console.log("Done"); does not show either

var dpumps =require('datapumps');
Pump = dpumps.Pump;
PostgresqlMixin= dpumps.mixin.PostgresqlMixin;
QueryStream = require('pg-query-stream');
Client = require('pg').Client;

var con = {
    host: 'localhost',
    port: 5432,
    database: 'mydatabase',
    user: 'myuser',
    password: 'mypass'
};

postgresqlClient = new Client(con) ;

exports.pump = function () {
    console.log("Ready To Pump"); //This logs so i know the function is called.
    postgresqlCopy = new Pump()
        .from(postgresqlClient.query(new QueryStream("SELECT $1~, $2~, $3~ FROM $4~ LIMIT 10",["RowId", "Company", "ArticleNo", "Article"])))
        .mixin(PostgresqlMixin(postgresqlClient))
        .process(function(data) {
            console.log("We are in the Process");
            return postgresqlCopy.log(data) ;
        })
        .logErrorsToConsole()
        .run()
        .then(function() {
            console.log("Done");
            console.log(postgresqlClient)
        });

};

I am referring to this I think there are some syntax errors there though



via flexxxit

No comments:

Post a Comment