Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mysql query node.js

const mysql=require('mysql2')

const connection = mysql.createPool({
    host: 'localhost',
    user:'root',
    password:'whatever it is',
    database: "whatever it is"
})

const sqlInsert = 'INSERT INTO reviews (fieldName1, fieldName2) values (?, ?)' // whatever query you want
connection.query(
  sqlInsert,
  [value1, value2], // inserts into '?' symbol
  (err, results, fields) => {
    if(err){
      console.log(err)
    }
    else{
      console.log(results)
    }
  }
)
 
PREVIOUS NEXT
Tagged: #mysql #query
ADD COMMENT
Topic
Name
9+1 =