我试图使用节点执行postgres查询,但由于某种原因,没有从postgres获取数据。
请参见下面的database.js:
const { Client } = require('pg'); const PORT = process.env.PORT || 3000; const client = new Client({ host: 'localhost', port: PORT, user: 'postgres', password: 'postgres', database: 'ecommerce' client.connect(); client.query('select * from customers', (err, result) => { if (!err) { console.log(result.rows) } else { console.log(err) client.end();