MySQL with Node.js(带有 Node.js 的 MySQL)
本文介绍了带有 Node.js 的 MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚开始接触 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.
如何将 MySQL 与 Node.js 结合使用?
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'
这篇关于带有 Node.js 的 MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:带有 Node.js 的 MySQL
基础教程推荐
猜你喜欢
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- Sql Server 字符串到日期的转换 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01