aardio dynamic mysql variable setting

Don't talk nonsense, just start working!

From the morning to the present! Finally some results!
The requirement is to read data from the database, according to conditions (variables)

Go directly to the code, if you have any questions, please correct me!


import console;
import mysql.client;

console.log("正在连接数据库服务器...");
thread.invoke( function()
        while(! thread.get("db4free.net:end")){
    
    
         io.stdout.write(">");sleep(100);
    }  
)

var dbMysql,err = mysql.client(
    server = "localhost"; //数据库服务器,可省略默认为localhost
    uid = "root";//用户名,可省略默认为root
    pwd = "root";  
);

thread.set("db4free.net:end",true)
console.clearScreen ();
if(!dbMysql){
    
    
    console.log("连接数据库失败",err);
    console.pause();
    return;
}

//选择数据库
dbMysql.selectDb("py")  

//执行SQL语句,注意mysql表名、字段名可包含于反引号内(用键盘左上角ESC下方的按键内)

//查询数据并返回记录集
le = "女士内衣/男士内衣/家居服"
le2 ="睡衣/家居服套装"
var result = dbMysql.query("SELECT level1,level2,level3,name FROM `cmf_role1` where level1='"+le+"' and level2='"+le2+"'");

for level1,level2,level3,name in result.each(){
    
    
    console.log( level1,level2,level3,name ); //逐行输出所有记录
}

//移除数据库
dbMysql.exec("DROP TABLE IF EXISTS `library`");
console.pause();

As shown

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_37254196/article/details/108363337