3
node-postgres 클라이언트를 AWS Redshift 데이터베이스에 사용하고 있습니다.AWS를 통한 Redshift 연결 시도 람다
로컬에서는 ">> connected"및 ">>> successful query. jsonResult :"에 대한 인쇄 명령문을 가져 와서 node
에 다음 코드를 실행할 수 있습니다.
그러나 Amazon Lambda에서이 코드를 실행하면 "연결하려고합니다 ..."와 같은 로그 문이 표시되지 않습니다.
console.log("trying to connect...");
var r = pg.connect(conString, function(err, client) {
if(err) {
return console.log('>> could not connect to redshift', err);
}
console.log(">> connected");
client.query('SELECT * FROM my_table', function(err, result) {
if(err) {
return console.log('error running query', err);
}
var jsonResult = JSON.stringify(result);
console.log(">>> successful query. jsonResult: " + jsonResult);
client.end();
return jsonResult;
});
});
이 코드에는 ">> 연결하려고합니다 ..."와 같은 print 문이 표시되지 않는 것과 혼동 스럽습니다.
node.js가 비동기 모드에서 함수를 실행 중입니다. 비동기 유틸리티 (https://github.com/caolan/async) – Guy
고맙다, 가이 사용을 고려하십시오. asynC# waterfall의 내부에서 호출을 감싸는 것은 더 나를 필요로합니다. –
이것에 대해 더 알고 싶습니까? 내가 옳은 대답은 현재 위의 코드가 비동기를 실행하고 콜백이 끝나기 전에 끝나는 것이라고 생각합니다. –