CNode

有没有操作MySql的Demo啊

Xxiuxu123发布于13 年前最后回复13 年前7 回复5672 浏览0 收藏

各位大神有没有操作MySql的Demo啊,简单点的就行,不要特别复杂的,就直接是增删改查的操作就行,我都是看的MongoDB的,操作MySQL就不行了!谢谢各位指点下,

查看回复

回复 (7)

H
hexie#1·13 年前

var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret', });

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

https://github.com/felixge/node-mysql

X
xiuxu123#2·13 年前

我只想对您说三个字: 非常感谢您,我已经成功了!

S
sumory#3·13 年前
H
hexie#4·13 年前
引用 hexievar mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user...

@sumory 这个写法,的确不合理,官网给出的,不过实际上,还是能跑,

var mysql = require('mysql'); var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret', });

connection.connect();

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

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

这样才是正解

Y
yakczh#5·13 年前

11个字,不算标点符号

参与回复
登录后即可参与回复。登录