Able to open database with different keys.
Prabhakaran2011 opened this issue · 1 comments
Prabhakaran2011 commented
AM trying to integrate the SqlCipher using this adapter in Ionic 4.
"@ionic/angular": "^4.1.0", "cordova-android": "8.0.0", "cordova-ios": "5.0.1", "cordova-sqlcipher-adapter": "0.4.0",
When I follow the procedure as mention in Readme documention, it opens the database. But unfortunatley am able to access the table values inside the database with different keys.
let db: any;
db = (<any>window).sqlitePlugin.openDatabase({ name: 'demo.db', key: 'key', location: 'default' });
db.transaction(tx => {
tx.executeSql('CREATE TABLE IF NOT EXISTS usertbl (id INTEGER PRIMARY KEY AUTOINCREMENT, loginid string, password string)');
tx.executeSql('INSERT INTO usertbl(loginid, password) VALUES (?,?)', ['id-123', 'password']);
}, (error) => {
console.log('Transaction ERROR: ' + error.message);
}, () => {
console.log('Success');
});
db.transaction((tx) => {
tx.executeSql('select * from usertbl', [], (tx, result) => {
console.log(result.rows.item(0));
});
}, (error) => {
console.log('Transaction ERROR: ' + error.message);
}, () => {
console.log('Populated database OK');
});
let db22: any;
db22 = (<any>window).sqlitePlugin.openDatabase({ name: 'demo.db', key: '123123qwe123', location: 'default' });
db22.transaction((tx) => {
tx.executeSql('select * from usertbl', [], (tx, result) => {
console.log(result.rows.item(0));
});
}, (error) => {
console.log('Transaction ERROR: ' + error.message);
}, () => {
console.log('Populated database OK');
});
When I use different keys to access the database, I can able to fetch results for both the keys, but I created record inside the transaction of DB inside the first key only. The same happens s for both Android and iOS.
Prabhakaran2011 commented
My bad. I failed to close the DB before using the other.