Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to load populated database #63

Open
CampaUTN opened this issue Aug 4, 2017 · 10 comments
Open

Failed to load populated database #63

CampaUTN opened this issue Aug 4, 2017 · 10 comments

Comments

@CampaUTN
Copy link

CampaUTN commented Aug 4, 2017

Hi
I cant load a populated database, its notrecognizing the .db file so its creating a new empty one. I have the plugins, the code is copied from here (also tried a lot of different sources):
https://github.com/iursevla/ionic2-PreDB

The plugin is acctually working? Because I see travis failing
In case the last version is working, do am i missing something apart from the 'guide' of that repository i have copied?

Thank you very much

private options = { name: "datos.db", location: 'default', createFromLocation: 1 };
private queryNames = "SELECT * FROM testTable";
public names: String[] = [];

constructor(public navCtrl: NavController, private sqlite: SQLite, private platform : Platform) {
this.platform.ready().then(() => {
    this.sqlite.create(this.options).then((db: SQLiteObject) => {
      db.executeSql(this.queryNames, {}).then((data) => {
        let rows = data.rows;
        alert(JSON.stringify(rows));
      }, err => {
          alert(JSON.stringify(err));
      })
    });
    })
  }

==> Return: no such testTable and sqlite_master no rows

@sofarojo
Copy link

Happens to me too

@shkhalid
Copy link

Did you found any solutions? i am also facing this problem.

@sofarojo
Copy link

sofarojo commented Aug 25, 2017 via email

@ergurjeet
Copy link

For me it's working flawlessly in Android, however, it's creating an empty DB in IOS 11.
Any solution or workaround will be appreciated.

@sofarojo
Copy link

@ergurjeet How did you make it work in Android?? I still got empty DB instead of my prepopulated one

@uselessai
Copy link

I am fancing the same error in iOS.. the same code in android is working perfectly..

@sofarojo
Copy link

@DetoloX which code is working for you? i can't make it work in android

@brodycj
Copy link
Owner

brodycj commented Oct 25, 2017

In case of issues with pre-populated databases: please start with https://github.com/brodybits/cordova-sqlite-ext-bootstrap-starter-app which has CC0 (public domain) license. In case of Ionic please try https://github.com/iursevla/ionic2-PreDB (Unlicense - also public domain, thanks @CampaUTN for pointing it out) or one of the other Ionic starters already documented.

IMPORTANT NOTE: Beware that the pre-populated database will NOT be copied if database with the same name was already copied or initialized. This is a common pitfall that was already documented.

@ergurjeet
Copy link

@sofarojo the example given on https://ionicframework.com/docs/native/sqlite/ with additional setting of createFromLocation:1 with https://github.com/litehelpers/cordova-sqlite-ext plugin is working for me on Android.
@brodybits, thanks for the links, I will give it a try. In IOS, it's stuck at "new transaction is waiting for open operation". Even tried (window as any).sqlitePlugin.selfTest(function() { console.log('SELF test OK'); }); console.log('Test executed'); (after device ready) and echoTest, but 'SELF test ok' was never printed in the console. Also, tried uninstalling and installing the plugins several times.

@sofarojo
Copy link

@brodybits @ergurjeet Thank you very much!!, finally It worked. I updated my project to the latest version of angular and ionic. I made some changes in my data service thanks to this guy nicobytes [https://github.com/ion-book/demo107]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants