2016-06-23 8 views

Antwort

0

Sie mysql npm Modul verwenden können: npm install mysql

var mysql  = require('mysql'); 
var pool = mysql.createPool({ 
    host: 'localhost' 
    user: 'youruser' 
    password: 'yourpassword' 
    database: 'yourdb' 
}); 

pool.getConnection(function (err, connection) { 
    connection.query('INSERT INTO tbl_name (col1,col2) VALUES(' + theValueYouGotFromAjax + ',' + anotherValue + ')' + '\'', function (err, result) { 
      if (err) console.log(err); 
      console.log('Created ' + result.affectedRows + ' rows'); 
      connection.release(); 
      console.log('Connection returned to pool.'); 
}); 

Prüfbaustein Dokumentation: https://github.com/mysqljs/mysql/tree/v0.9

Verwandte Themen