postegreSQL inserting query using node js


I have this code on index.js in which i connect to a postgreSQL database and execute a query but it keeps telling me: column "Jhonny" does not exist.
Here is my code:

const {Client} = require ('pg');

    const client = new Client({
        host: 'localhost',
        user: 'postgres',
        database: 'React',
        password: '01021997',
        port: 5432,
    client.query('INSERT INTO movies (moviename, review) VALUES ("Jhonny", "no 
    review");', (err, res)=>{
            console.log('insert done');


the query should be in the following way:

client.query(`INSERT INTO "movies" ("moviename", "review") VALUES ('Jhonny', 
'no review');`

the column names and the table name should be between ("") and the values should be between (”).

Answered By – user19069531

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published