Giter Club home page Giter Club logo

Comments (2)

brodybits avatar brodybits commented on September 14, 2024

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-ext

There 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.

FaraTar avatar FaraTar commented on September 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.