MySQL with Node.js(MySQL 与 Node.js)
本文介绍了MySQL 与 Node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始接触 Node.js.我来自 PHP 背景,所以我相当习惯于使用 MySQL 来满足我所有的数据库需求.
I've just started getting into Node.js. I come from a PHP background, so I'm fairly used to using MySQL for all my database needs.
如何在 Node.js 中使用 MySQL?
How can I use MySQL with Node.js?
推荐答案
查看 node.js 模块列表
- node-mysql — 实现 MySQL 协议的 node.js 模块
- node-mysql2 — 又一个纯 JS 异步驱动程序.流水线,准备好的语句.
- node-mysql-libmysqlclient — 基于 libmysqlclient 的 MySQL 异步绑定
- node-mysql — A node.js module implementing the MySQL protocol
- node-mysql2 — Yet another pure JS async driver. Pipelining, prepared statements.
- node-mysql-libmysqlclient — MySQL asynchronous bindings based on libmysqlclient
node-mysql 看起来很简单:
node-mysql looks simple enough:
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'example.org',
user : 'bob',
password : 'secret',
});
connection.connect(function(err) {
// connected! (unless `err` is set)
});
查询:
var post = {id: 1, title: 'Hello MySQL'};
var query = connection.query('INSERT INTO posts SET ?', post, function(err, result) {
// Neat!
});
console.log(query.sql); // INSERT INTO posts SET `id` = 1, `title` = 'Hello MySQL'
这篇关于MySQL 与 Node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:MySQL 与 Node.js


基础教程推荐
猜你喜欢
- 带更新的 sqlite CTE 2022-01-01
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01