| 
	
	
		
		
			
			 
				Подключение к postgresql из node.js
			 
			
		
		
		
		Хочу подключиться к БД. порядок действий: 
1. создаю с помощью init package.json 
2. устанавливаю pg 
Код: 
const {Client} = require('pg'); 
 
const db = new Client({ 
    user:'postgres', 
    host:'localhost', 
    password:'12345', 
    port:5432 
}) 
 
db.connect() 
 
db.query('SELECT * FROM students',(err, data) =>{ 
    console.log(err, data); 
    db.end() 
     
}) 
Запускаю, получаю ошибку: 
UnhandledPromiseRejectionWarning: error: ���� ������ "*****" �� ���������� 
    at Connection.parseE (D:\nodejs\node_modules\pg\lib\connection.js:555:1  1) 
    at Connection.parseMessage (D:\nodejs\node_modules\pg\lib\connection.js:380:1  9) 
    at Socket.<anonymous> (D:\nodejs\node_modules\pg\lib\connection.js:120:2  2) 
    at Socket.emit (events.js:182:13) 
    at addChunk (_stream_readable.js:283:12) 
    at readableAddChunk (_stream_readable.js:264:11) 
    at Socket.Readable.push (_stream_readable.js:219:10) 
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17) 
(node:8908) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) 
(node:8908) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. 
Error: Connection terminated unexpectedly 
    at Connection.con.once (D:\nodejs\node_modules\pg\lib\client.js:200:9) 
    at Object.onceWrapper (events.js:273:13) 
    at Connection.emit (events.js:182:13) 
    at Socket.<anonymous> (D:\nodejs\node_modules\pg\lib\connection.js:76:10  ) 
    at Socket.emit (events.js:182:13) 
    at TCP._handle.close (net.js:610:12) undefined 
подскажите, что я делаю не так? 
		
	
		
		
		
		
		
		
	
		
			
			
	
			
			
			
			
			
				 
			
			
			
			
			
			
				
			
			
			
		 
		
	
	
	 |