NodeJs使用Mysql模块实现事务处理实例

2024-08-03 17:24:54
二建小科普
二建小科普认证

二建小科普为您分享以下优质知识

先npm install mysql

然后代码中就可以require('mysql');

就可以使用了

var mysql = require('mysql');var pool= mysql.createPool(config);pool.getConnection(function(err, connection) {// Use the connectionconnection.query( 'SELECT something FROM sometable', function(err, rows) {// And done with the connection.connection.end();// Don't use the connection here, it has been returned to the pool.});});

js代码透明,你在写好代码提交给别人的时候,或是部署的时候,用

Jshaman

给代码加密一下,别人就看不了你的代码了