如何使用nodejs与mysql进行数据交互

先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) {// ...
如何使用nodejs与mysql进行数据交互
先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给代码加密一下,别人就看不了你的代码了
2018-09-20
mengvlog 阅读 50 次 更新于 2025-10-29 16:03:17 我来答关注问题0
檬味博客在线解答立即免费咨询

mySQL相关话题

Copyright © 2023 WWW.MENGVLOG.COM - 檬味博客
返回顶部