123456789101112131415161718192021 |
- const { Client } = require('pg')
- const client = new Client({
- user: 'postgres',
- host: 'localhost',
- database: 'testdb',
- password: '1234abcd',
- port: 5432,
- });
- client.connect()
- client.query('SELECT NOW()', (err, res) => {
- if (err) {
- console.error(err);
- return;
- }
- console.log('Connection successful');
- client.end()
- });
|