admin管理员组文章数量:1320603
I am going to make a client-server application using Node.js, and I want to use a MySQL database for storing some of the data. I need to know how to query a database with server-side JavaScript.
I am going to make a client-server application using Node.js, and I want to use a MySQL database for storing some of the data. I need to know how to query a database with server-side JavaScript.
Share Improve this question edited Mar 30, 2012 at 8:08 Thein Hla Maw 6831 gold badge9 silver badges28 bronze badges asked Mar 29, 2012 at 12:27 WingbladeWingblade 10.1k10 gold badges36 silver badges52 bronze badges2 Answers
Reset to default 5Search the module library for mysql and you will get many modules that will let you do that including mysql, db-mysql, and easy-mysql.
npm install node-mysql
var mysql = require('mysql'),
client = mysql.createClient({
user: 'root',
password: 'root',
});
mysql.query('SELECT * FROM my_table', function(err, results, fields) {
//have fun
client.end();
});
There are other libraries as well that all have slightly different APIs.
本文标签: javascriptHow can I query MySQL with nodejsStack Overflow
版权声明:本文标题:javascript - How can I query MySQL with node.js? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742080122a2419648.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论