我需要为我的应用使用2个sqlite数据库
这两个数据库有一些结构,因为其中一个是StoricDB
在某些程序中,我需要同时使用db。
我执行此代码:
var onDeviceReady = function ()
{
testwith2db();
};
document.addEventListener("deviceready", onDeviceReady, true);
function testwith2db (){
var dbCurrent_path = "/sdcard/Android/data/myDatabase/DbCurrent"
var dbStoric_poath = "/sdcard/Android/data/myDatabase/DbStoric"
// this work fine
var db_current = window.sqlitePlugin.openDatabase(dbCurrent_path , "1.0", "DbCurrent", 10000000);
db_current.transaction(doquerycurrent, on_tran_error, on_tran_success);
//this work fine
var db_storic = window.sqlitePlugin.openDatabase(dbStoric_poath , "1.0", "DbStoric", 10000000);
db_storic.transaction(doquerystoric, on_tran_error, on_tran_success);
/*
following lines are my problem
because if i do:... another query on currentdb, the query is alwais executed on last db opened
for me is impossible to use currentdb again
*/
var db_current = window.sqlitePlugin.openDatabase(dbCurrent_path , "1.0", "DbCurrent", 10000000);
db_current.transaction(doquerycurrent, on_tran_error, on_tran_success);
}
function doquerycurrent(txc){
// strange behaviour
// this query is executed on storic db if a have opened it
txc.executeSql("SELECT * FROM table1", [],[]);
}
function doquerystoric(txs){
txs.executeSql("SELECT * FROM table1", [],[]);
}
我尝试使用附加db形式我的查询但不支持android ????
tx.executeSql("ATTACH DATABASE '/mnt/sdcard/Android/data/myDatabase/DbStoric' as S",[], on_query_success) // this line return error
请帮帮我 感谢