intern-Assignment/PostgreSQL/test/main.js

25 lines
437 B
JavaScript
Raw Normal View History

2025-01-31 09:50:39 +00:00
const {Client} = require('pg');
const connection = new Client({
host: "localhost",
user: "postgres",
port: 5432,
password: "password",
database: "mydb"
})
connection.connect().then(() => console.log("Connected to the database"))
connection.query('Select * from weather', (err, res) => {
if(!err){
console.log(res.rows);
}
else{
console.log(err.message);
}
connection.end;
})