C# · 12月 20, 2021

javascript + sql编写SQL客户端工具tabris

<div style=”font-size: 14px; white-space: pre-wrap; text-align: left; line-height: 1.75;”>祝大家2018新年快乐,
<div style=”font-size: 14px; white-space: pre-wrap; text-align: left; line-height: 1.75;”>前不久发现了一个创意的脚本<span style=”font-size: 28px; color: #24292e;”>Jtsql(java编写)

别误会成客户端运行啊…) 1 包含JtSQL的所有特性

封装的sql log http 三大组件 在编辑器上的方法能代码智能提示 

<img src=”https://www.jb51.cc/res/2019/02-15/23/ca9db959d20a7a764f492d9c788c47ea.png” alt=””>

<img src=”https://www.jb51.cc/res/2019/02-15/23/97887748187337470b0dddf4ffaa4fc6.png” alt=””>
<div class=”cnblogs_code”>

db = .tabris.create(‘sql”testorm”MysqL'<span style=”color: #008000;”>//<span style=”color: #008000;”>http处理器
<span style=”color: #0000ff;”>var http = <span style=”color: #0000ff;”>this.tabris.create(‘HTTP'<span style=”color: #000000;”>,{
method:’GET'<span style=”color: #000000;”>
});

<span style=”color: #008000;”>//<span style=”color: #008000;”>log处理器
<span style=”color: #0000ff;”>var log = <span style=”color: #0000ff;”>this.tabris.create(‘LOG'<span style=”color: #000000;”>,{
trace:<span style=”color: #0000ff;”>true<span style=”color: #000000;”>
});

db.<span style=”color: #0000ff;”>delete(‘delete from child_district'<span style=”color: #000000;”>);

<span style=”color: #008000;”>//<span style=”color: #008000;”>从district表里面获取所有城市的Code
<span style=”color: #0000ff;”>var getdistrictsql = “select Code from district”<span style=”color: #000000;”>;

<span style=”color: #0000ff;”>var district_code_list =<span style=”color: #000000;”> db.query(getdistrictsql);

<span style=”color: #0000ff;”>for (<span style=”color: #0000ff;”>var index = 0; index < district_code_list.length; index++<span style=”color: #000000;”>) {
getChildDistrictAndInsertToDb(district_code_list[index].Code);
}

<span style=”color: #008000;”>//<span style=”color: #008000;”>远程获取
<span style=”color: #0000ff;”>function<span style=”color: #000000;”> getChildDistrictAndInsertToDb(parentCode){
log.info(parentCode);
<span style=”color: #0000ff;”>var re =<span style=”color: #000000;”> http.getJson({
url:’https://fuwu.sf-express.com/service/address/newAddr/getNewSubAddress?parentCode=’ +<span style=”color: #000000;”> parentCode
});
<span style=”color: #0000ff;”>if(!re.subAddressList || !re.subAddressList.length) <span style=”color: #0000ff;”>return<span style=”color: #000000;”>;
<span style=”color: #0000ff;”>for (<span style=”color: #0000ff;”>var index = 0; index < re.subAddressList.length; index++<span style=”color: #000000;”>) {
<span style=”color: #0000ff;”>var child =<span style=”color: #000000;”> re.subAddressList[index];
<span style=”color: #0000ff;”>var insertsql = “insert into child_district (Name,Code,DataChange_LastTime) VALUES(‘”+ child.distCnName +”‘,'”+ child.distCode +”‘,Now())”<span style=”color: #000000;”>;
<span style=”color: #0000ff;”>var insertResult =<span style=”color: #000000;”> db.insert(insertsql)
<span style=”color: #0000ff;”>if(insertResult!=1<span style=”color: #000000;”>){
log.error(child.distCnName + ‘插入db失败!'<span style=”color: #000000;”>);
}<span style=”color: #0000ff;”>else<span style=”color: #000000;”>{
log.info(child.distCnName + ‘插入db成功!'<span style=”color: #000000;”>)
}
}
}

下载地址