“Instalasi MySQL2” Kode Jawaban

Instalasi MySQL2

npm install --save mysql2
Rich Rabbit

Instalasi MySQL2

// get the client
const mysql = require('mysql2');

// create the connection to database
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  database: 'test'
});

// simple query
connection.query(
  'SELECT * FROM `table` WHERE `name` = "Page" AND `age` > 45',
  function(err, results, fields) {
    console.log(results); // results contains rows returned by server
    console.log(fields); // fields contains extra meta data about results, if available
  }
);

// with placeholder
connection.query(
  'SELECT * FROM `table` WHERE `name` = ? AND `age` > ?',
  ['Page', 45],
  function(err, results) {
    console.log(results);
  }
);
Rich Rabbit

Jawaban yang mirip dengan “Instalasi MySQL2”

Pertanyaan yang mirip dengan “Instalasi MySQL2”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya