Ionic 3 SQLite: SQLiteObject's method executeSql() not working

What I have done:

  1. Installed ionic today, by the command npm install -g ionic and saying ‘y’ to the cordova integration.

  2. Installed cordova: npm install -g cordova

  3. Created a new project: ionic start sqlite3demo blank

  4. Installed Ionic native storage:

    ionic cordova plugin add cordova-sqlite-storage

    npm install --save @ionic-native/sqlite

Now for the code. I imported SQLite into app.module.ts like this:

    import { BrowserModule } from '@angular/platform-browser';
    import { ErrorHandler, NgModule } from '@angular/core';
    import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
    import { SplashScreen } from '@ionic-native/splash-screen';
    import { StatusBar } from '@ionic-native/status-bar';
    import { SQLite } from '@ionic-native/sqlite';
    import { MyApp } from './app.component';
    import { HomePage } from '../pages/home/home';
      declarations: [
      imports: [
      bootstrap: [IonicApp],
      entryComponents: [
      providers: [
        {provide: ErrorHandler, useClass: IonicErrorHandler},
    export class AppModule {}

And then, I modified the default home page like this:

          SQLite demo
    <ion-content padding>
        <button ion-button (click)="createTables()">Create db</button>
        <p>Result: {{ message }}</p>

And finally, I modified home.ts like this:

    import { Component } from '@angular/core';
    import { NavController, Platform } from 'ionic-angular';
    import { SQLite, SQLiteObject } from '@ionic-native/sqlite';
      selector: 'page-home',
      templateUrl: 'home.html'
    export class HomePage {
      message = '';
      db: SQLiteObject;
      constructor(private platform: Platform, public navCtrl: NavController, private sqlite: SQLite) {
        this.platform.ready().then(() => {
            name: 'todos.db',
            location: 'default'
            .then((db: SQLiteObject) => {
              this.message = JSON.stringify(db);
              this.db = db;
      public createTables() {
        return this.db.executeSql(
          `CREATE TABLE IF NOT EXISTS list (
            name TEXT
          .then(() => this.message = 'OK')
          .catch((err) => this.message = "error detected creating tables -> " + JSON.stringify(err));

After all that, I execute ionic cordova run android, and I can see the JSON from db, but after that, I click the button to create a table and instead of seeing ‘OK’, I see the JSON from the error.

What did I do wrong? Why isn’t it working?

After 4 days, I’m starting to feel lonely…

Hello, have you tried running the app on your cell phone? and debug with the Chrome DevTools to see the errors that SqLite could give?
I do not see problems in the code should work.

It is better to keep database logic seperate.
I’ve already created Database provider file for faster development.
Please see this answer and modify your code accordingly.
Let me know if you still have any issue.