跳到主要内容
CNode

有没有操作MySql的Demo啊

社区
Xxiuxu123发布于 13 年前最后回复 13 年前
757090

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

查看回复

回复 (7)

Y
yakczh#513 年前

11个字,不算标点符号

H
hexie#413 年前
引用 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); });

这样才是正解

X
xiuxu123#213 年前

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

H
hexie#113 年前

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

参与回复

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