Connect To PostgreSQL

suggest change

Use the pg npm module. Install it with npm:

npm install pg --save

Create a PostgreSQL client, which you can query later.

This example assumes the database name is students, the host is localhost, and the user is postgres. The URL scheme is postgres://, not pg://.

var pg = require("pg")
var connectionString = "postgres://postgres:postgres@localhost:5432/students";
var client = new pg.Client(connectionString);
client.connect(function (err) {
    if (err) throw err;
});

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents