0
嗨我三天前開始學習node.js,並且我一直在嘗試使用數據轉儲。到目前爲止,我正在使用Express運行節點js,問題是我的進程函數從不運行。我在日誌中看到這個console.log("Ready To Pump");
,所以我可以告訴該函數被調用。然而,這個過程似乎是掛起的。 (不確定)。由於console.log("We are in the Process");
部分代碼未顯示在日誌中,因此未調用進程功能。我在哪裏出錯了。我也知道我的連接字符串工作,因爲我有另一個功能,使用相同的查詢並將數據記錄到控制檯。我打算將數據從一個Postgre數據庫傳輸到另一個數據庫。當然,如果我的過程函數從未被調用,我無法做到這一點。我也沒有在控制檯中發現任何錯誤。我相信它掛起,因爲console.log("Done");
不顯示任何帶PostgreSQL的NodeJs DataPumps:進程掛起
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)
});
};
我指的是this我覺得有一些語法錯誤出現雖然
我做到了,但我仍然沒有看到任何東西。我意識到它不會掛起,但它不會運行 – flexxxit