2

我需要为我的应用程序使用 2 个 sqlite 数据库,这两个数据库具有某种结构,因为其中一个数据库StoricDB 在某些过程中我需要同时使用两个数据库。

我做这个代码:

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", [],[]);

}

我已经尝试使用附加数据库表单我的查询,但不支持 android ????

tx.executeSql("ATTACH DATABASE '/mnt/sdcard/Android/data/myDatabase/DbStoric' as S",[], on_query_success)  // this line return error

请帮帮我谢谢

4

0 回答 0