Express connect to mysql

MySQL

Modulemysql

Installation

$ npm install mysql

Example

var mysql = require('mysql')
var connection = mysql.createConnection({
  host     : 'localhost',
  user     : 'dbuser',
  password : 's3kreee7',
  database : 'my_db'
});

connection.connect()

connection.query('SELECT 1 + 1 AS solution', function (err, rows, fields) {
  if (err) throw err

  console.log('The solution is: ', rows[0].solution)
})

connection.end()


Reference
https://expressjs.com/en/guide/database-integration.html
https://www.terlici.com/2015/08/13/mysql-node-express.html
https://codeburst.io/build-a-rest-api-for-node-mysql-2018-jwt-6957bcfc7ac9
https://github.com/waiyaki/postgres-express-node-tutorial/blob/master/
http://docs.sequelizejs.com/manual/tutorial/models-usage.html#data-retrieval-finders

Comments

Popular posts from this blog

M5Stack ESP32

How to debug msbuild