Learn how to create a Simple Application by Connecting PostgreSQL with NodeJs, While you are using PostgreSQL as database and NodeJs as backend, you need PostgreSQL database packages to connect with nodejs. There are various packages available but most popular and well documented is node-postgres pg. Let’s start.
- Make sure you have postgresql installed on machine and pgAdmin - postgresql management tool
- Make sure you have node.js installed
- Download the project’s zip
- After Creating Database, Check your Connection Strings and Create new table in PostgreSQL
CREATE TABLE customer2
(
id serial NOT NULL,
first_name character varying(200) NOT NULL,
last_name text NOT NULL,
location character varying(200) NOT NULL,
)
- Type npm install in terminal/console in the source folder where package.json is located
- Type node app.js in terminal/console in the source folder where api.js is located