|
- import console;
- import sqlite
- var tab1={"symbol";"title";"reason"}
- var tab2={{"300390.SZ";"天华超净";"新能源汽车"};{"000596.SZ";"古井贡酒";"白酒涨价"}}
- var db=sqlite("\beta.db")
- var str="CREATE TABLE IF NOT EXISTS zt(%s);"
- var str1=string.join(tab1,",")
- db.exec(str,str1)
- /*
- db.exec("CREATE TABLE IF NOT EXISTS zt(symbol,title,reason);")
- for(i=1;#tab2;1){
- db.prepare("INSERT INTO [zt] VALUES (@symbol,@title,@reason);").step({symbol=tab2[ i ][1];title=tab2[ i ][2];reason=tab2[ i ][3];})
- }
- */
- var strii=""
- for(i=1;#tab1;1){
- strii=string.concat(strii,"@",tab1[ i ],",")
- }
- strii=string.trimright(strii,",")
- //console.log(strii)
- var stri="INSERT INTO [zt] VALUES (%s);"
- stri=string.format(stri,strii)
- for(i=1;#tab2;1){
- db.prepare(stri).step(for(j=1;#tab1;1){tab1[j]=tab2[ i ][j]})//这句该怎么写?????
- }
- console.pause(true);
复制代码 |
|