本文共 1108 字,大约阅读时间需要 3 分钟。
var mysql = require(" mysql");
var mysql_config = {
主持人:" 127.0.0.1",
端口:\ 3306,
用户:\ "根",
密码:" 123124",
数据库:\ "乱序"
};
var 连接= mysql.createConnection(mysql_config);
功能handleDisconnect(){
connection.connect(函数\\ r){
如果(错误){
console.log(err);
console.log(\\\\尝试连接到\\)。
setTimeout(handleDisconnect,1000); //1秒后尝试重新连接
返回;
}
console.log(\"成功\");
});
}
handleDisconnect();
connection.query(\ quot;使用dorder \ quot;);
var querySql \ = \ \ quot;选择\ * \\ n来自 `e_customer` \ quot ;;
connection.query(querySql,函数(err,行){
如果(错误){
抛出\呃;
}
var jsonData \ = \ JSON.stringify(行);
console.log(jsonData);
for(var i = 0; i \ lt; rows.length; i ++){
console.log(\ quot; uuid \\-\ gt; \ +行[i].uuid)
console.log(\\\\ customerId \\-\ gt; \ +行[i].customerId);
console.log(\\\\ customerName \\-\ gt; \ + + [行[i].customerName);
console.log(\\\\ customerSource \\-\\\ gt; \ + + [第[i]行。customerSource);
console.log(" sourceSign"--u0026 gt; \ +行[i].sourceSign);
console.log(\\\ quot; sourceAddress \\-\ gt; \ +行[i].sourceAddress);
console.log(\ quot; createTime \\-\ gt; \ +行[i].createTime);
console.log(\\\\ n \);
}
});
connection.end();
转载地址:http://weqhp.baihongyu.com/