Recently in writing Websql, every time in the browser console to execute SQL too laborious, and the brain is not good, always forget what the last initialized database, so wrote a very simple websql visualization tool, said the tool is a bit large, is to facilitate, today shared out, the need of classmates, Please take away, did not do too much logic judgment, have the question can reply me, I again to revise, do not spray ~ ~
I. Description
1. INSERT
Support multiple Insert statements, with "#" split, the last sentence does not add:,
INSERT into Student (id,name) VALUES (1, "Zhangsan"), #INSERT into Student (id,name) VALUES (2, "Lisi"); #INSERT into Student ( Id,name) VALUES (3, "Wangwu");
2, delete, modify, query according to normal SQL writing can be.
Second, the source code
var Dataprovider = (function () {function Dataprovider () {} DataProvider.prototype.init = function () {This.provider = OpenDatabase (' madidb ', ' 1.0 ', ' MaDI DB ', 2 * 1024 * 1024); }; DATAPROVIDER.PROTOTYPE.EXECUTESQL = function (sql) {var data = $ ("Result_data"); var nt = "******************************************************************************************************* <br/> "; This.provider.transaction (function (context) {Context.executesql (Sql,[],function (context,results) { if (results.rows.length>0) {for (var i = 0,len = results.rows.length;i<len;i++) { data.innerhtml + = Json.stringify (Results.rows[i]) + "<br/>"; }}else{data.innerhtml + = "success<br/>"} Data.inner Html+=nt},function (context,error) {data.innerhtml + = "{ErrorCode:" +error.code+ ", Message:" +ERROR.M Essage+ "}<br/> "; Data.innerhtml+=nt; }); }); }; return dataprovider;}) ();
The rest of the code is all in Websql.rar and can be downloaded directly.
:
Websql Query Tool