常用sql 常用sql

常用sql

var express = require('express');
var router = express.Router();
var cookieParser = require('cookie-parser');
var session = require('cookie-session');
var md5=require("md5");
var mysql = require('mysql');
var sql1=require("../../libs/sql");
var session = require('express-session');
let sql={
   	 selectSql(sql,dataBase) {
	             var promise = new Promise(function(resolve,reject) {
	                 var result = null;
	                 var mysql = require('mysql');
	                 var connection = mysql.createConnection({
	                 host: 'localhost',
	                 user: 'root',
	                 password: ''
	                 });
	 
	                 connection.connect();
	                 connection.query(dataBase);
	                 connection.query(sql, function (err, results, fields) { 
	                     if (err) { 
	                         console.log("err");
	                         reject({status:"400",err:err,msg:"无数据"}); 
	                     }else {
	                          resolve({status:"200",data:results,msg:"成功!"});
	                         }
	                                  
	                      
	                 } 
	                 );
	                 connection.end(); 
	             })
	 
	             return promise; 
	      },
 };
 module.exports=sql;
分享本文至:

评论 0

挤眼 亲亲 咆哮 开心 想想 可怜 糗大了 委屈 哈哈 小声点 右哼哼 左哼哼 疑问 坏笑 赚钱啦 悲伤 耍酷 勾引 厉害 握手 耶 嘻嘻 害羞 鼓掌 馋嘴 抓狂 抱抱 围观 威武 给力
提交评论

清空信息
关闭评论