Sunday, February 12, 2017

Integrating Express with MySQL

MySQL

Modulemysql Installation
$ npm install mysql
Example
var mysql = require('mysql')
var connection = mysql.createConnection({
  host: 'localhost',
  user: 'dbuser',
  password: 's3kreee7'
})

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()

More at http://expressjs.com/en/guide/database-integration.html#mysql

C:\Node4Express\pms4express>npm install mysql
pms4express@0.0.0 C:\Node4Express\pms4express
`-- mysql@2.13.0
  +-- bignumber.js@3.1.2
  +-- readable-stream@1.1.14
  | +-- core-util-is@1.0.2
  | +-- isarray@0.0.1
  | `-- string_decoder@0.10.31
  `-- sqlstring@2.2.0

No comments:

Post a Comment