Comments (2)
On May 4, 2016 6:06 PM, "FaraTar" [email protected] wrote:
Hi,
I want to write an application with a pre- populated db. There for I used
the cordova-sqlite-extThere for I tried the quickstart guid and it went well. If I create a db
on start up it went well, too.
But If I try to use my db in the www directory, I get an error evry time
I tries to insert code in an existing table.`var db = window.sqlitePlugin.openDatabase({ name: "Orders.db", location:
1, createFromLocation: 1 });db.transaction(function (tx) { tx.executeSql('DROP TABLE IF EXISTS tb_auftrag'); tx.executeSql('CREATE TABLE IF NOT EXISTS tb_auftrag (auftragid
integer primary key, kdnr integer)');
tx.executeSql("INSERT INTO tb_auftrag (auftragid, kdnr) VALUES
(?,?)", [12356, 100], function (tx, res) {
console.log("insertId: " + res.insertId + " -- probably 1");
console.log("rowsAffected: " + res.rowsAffected + " -- should
be 1");db.transaction(function (tx) { tx.executeSql("select auftragid, kdnr from tb_auftrag;",
[], function (tx, res) {
console.log("res.rows.length: " + res.rows.length );
for (i = 0; i <= res.rows.length;i++){
console.log("res.rows.item("+i+").auftragid: " +
res.rows.item(i).auftragid);
console.log("res.rows.item("+i+").kdnr: " +
res.rows.item(i).kdnr);
}
},
function (e) { console.log("Select Error:" + e.message)
});}); }, function (e) { console.log("ERROR: " + e.message); }); });`
This code works well.
If I set the DROP and CREATE statements to comment I can use the database
created once and manipulate and read the data.
I think I can understand up to here.
But the select ignores all inputs created with SQLiteBrowser in the
prepopulated DB and also if I browse the db in www folder I only get the
inputs I created with the SQLiteBrowser.
I am not sure if I understand this part 100%.
Keep in mind that this plugin only reads the pre-populated database the
first time you run the app unless you erase the app data. To test the
pre-populated database step or is recommended to delete and reinstall your
app.
Also the database is copied from the www directory. The database in the www
directory will never be overwritten.
I tried the cordova-plugin-dbcopy to set the db in to the correct
directory and I get the responses the db still exists.
I am not sure if I can follow this part.
As a general comment I included the pre-populated database feature due to
popular demand. I would personally favor populating the database from a
dump or fetching the data over HTTP instead.
from cordova-sqlite-ext.
Thank you for your fast response.
I am sorry for writting kind a confused.
Allright I' ll take your soloution to use a dump file.
Thanks again.
from cordova-sqlite-ext.
Related Issues (20)
- [Feature Request] Please add an ability to read pre-populated db file which is encrypted by SQLCipher HOT 1
- New android apk does not update the device db. Is this normal? HOT 2
- IOS Shared App Group, how to? HOT 2
- issues in windows UWP HOT 2
- update populated database HOT 1
- cascading selects HOT 1
- Any plans to support the sqlite spatial extensions? HOT 2
- Cordova IOS insert/select out of column order. HOT 1
- Failed added plugin to [email protected] HOT 3
- Getting error while building after adding [email protected] HOT 1
- any reports of hangs with [email protected] and later ? HOT 9
- Cannot Open pre populated database. HOT 1
- Background thread per db
- Using the plugin with Ionic v4/v5
- Support for Android SDK v30 HOT 21
- DB not opening on oneplus7t Pro, Vivo V2050, RealMe 7i HOT 2
- Could not open database
- Query with RENAME breaks on Android 8, 9 and 10, but only with new versions HOT 1
- Google API Level 33 support HOT 1
- adding support electron
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-sqlite-ext.