时间:2021-07-01 10:21:17 帮助过:3人阅读
test.js
const mysql = require (‘mysql‘); var mysqlconfig=require(‘./mysql_config‘).mysqlconfig; var db = mysql.createConnection(mysqlconfig); var sql = ‘SELECT * FROM name‘; //查詢條件 var userAddSql = ‘INSERT INTO name(id,uname,times) VALUES(0,?,?)‘; var userAddSql_Params = [‘hahah‘, 5699]; db.query(userAddSql,userAddSql_Params,(err,data)=>{ //查詢數據 if(err) console.log(‘出錯了!‘,err); else{ console.log(‘--------------------------insert----------------------------‘); console.log(‘INSERT ID:‘,data); console.log(‘------------------------------------------------------------\n\n‘); } }); db.query(sql,(err,data)=>{ //查詢數據 if(err) console.log(‘出錯了!‘,err); else{ console.log(‘--------------------------SELECT----------------------------‘); console.log(‘成功了!‘,data); console.log(‘------------------------------------------------------------\n\n‘); } });
nodejs mysql 配置引用
标签:配置 else console add 引用 from node select bsp