当前位置: 代码迷 >> 综合 >> javascript读写本地sqlite数据库
  详细解决方案

javascript读写本地sqlite数据库

热度:88   发布时间:2024-01-15 04:54:03.0

sqlite这种单文件数据库,类型简单功能强大效率也不错,非常适合单机软件开发。

把一个我以前写的JavaScript sqlite数据库操作类分享给大家,还是先上代码,注释写的很清楚啦,支持增删改查,支持链式查询,使用的时候不用new。

/*sqlite数据库操作类 by sdxjwkq01*/
this.Db={tableName:"",//表whereReg:"",//where条件orderReg:"",//排序条件pageReg:"",//分页dbUrl:"DRIVER=SQLite3 ODBC Driver;Database=Db/database.db",//数据库地址//取得表table:function(tableName){this.tableName=tableName;return this;},//取得wherewhere:function(whereReg){this.whereReg=whereReg;return this;},//排序order:function(orderReg){this.orderReg=orderReg;return this;},//分页page:function(pageReg){this.pageReg=pageReg;return this;},//添加add:function(json){var sql="insert into "+this.tableName+"(";var fields=[];var values=[];for(var item in json){fields.push(item);values.push(&
  相关解决方案