PostgreSQL 언어 데이터베이스에 node-postgres 연결
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
이 페이지에서는 PostgreSQL node-postgres 드라이버를 Spanner의 PostgreSQL 언어 데이터베이스에 연결하는 방법을 설명합니다. node-postgres는 PostgreSQL용 Node.js 드라이버입니다.
PGAdapter가 PostgreSQL node-postgres 드라이버를 사용하여 연결하는 애플리케이션과 같은 머신에서 실행 중인지 확인합니다.
자세한 내용은 PGAdapter 시작을 참조하세요.
node-postgres
연결 속성에서 localhost
및 5432
를 데이터베이스 서버 호스트와 포트로 지정합니다.
- 필요한 경우 PGAdapter가 기본 PostgreSQL 포트(5432)가 아닌 다른 포트에서 리슨하도록 구성되면 포트 번호를 지정합니다.
- 원하는 경우 PGAdapter가 로컬 머신과 다른 호스트에서 실행 중이면 다른 호스트 이름을 지정합니다.
const { Client } = require('pg');
const client = new Client({
host: 'localhost',
port: 5432,
database: 'my-database',
});
await client.connect();
const res = await client.query("select 'Hello world!' as hello");
console.log(res.rows[0].hello);
await client.end();
다음 단계
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-03-22(UTC)
[{
"type": "thumb-down",
"id": "hardToUnderstand",
"label":"Hard to understand"
},{
"type": "thumb-down",
"id": "incorrectInformationOrSampleCode",
"label":"Incorrect information or sample code"
},{
"type": "thumb-down",
"id": "missingTheInformationSamplesINeed",
"label":"Missing the information/samples I need"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"번역 문제"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"기타"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"이해하기 쉬움"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"문제가 해결됨"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"기타"
}]