Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 229599

How to connect to a SQLite DB?

$
0
0

Hello,
I'm a ionic beginner and I'm in trouble.
In my app.component.ts, I've wrote this :

export class MyApp {
rootPage:any = LoginPage;
private db: SQLiteObject;

constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private sqlite: SQLite) {
platform.ready().then(() => {
this.createDB();
statusBar.styleDefault();
splashScreen.hide();
});
}

private createDB() {
this.sqlite.create({
name: 'myDB.db',
location: 'default'
})
.then((db: SQLiteObject) => {
alert('base de données créée')
this.db = db;
this.createTable();
})
.catch(e => alert(e));
}

private createTable() {
this.db.executeSql('CREATE TABLE IF NOT EXISTS SIGNALEMENTS ( `... )', {})
.then(() => alert('Table créée'))
.catch(e => console.log(e));
}
}

It works well, my DB was created (is the default location is android/data ?) but how to connect/open to this database local storage from another page to insert my sql queries ?
Could any one help me please ?
Thanks in advance...

P.S. : Another question, from this sqlite local storage database, I would like to export all theses datas to an online SQL database. May I use the Ionic Native SQLite Porter plugin to do this ?


Viewing all articles
Browse latest Browse all 229599

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>