Thursday, 25 January, 2018 UTC


Summary

  • Additional we add the SQLite Porter plugin as well as the according Ionic Native NPM packages so we can populated our SQL database from e.g. a given SQL dump.
  • Once our platform is ready we create or open a new SQLite database on our device, and once we are ready we can fill the database with our SQL dump.
  • If we now want to add a developer, we can again perform a SQL query to insert the new data into our database.
  • When we add a developer we expect the database to be ready already, we just call the according function of our provider to insert a new row into our SQLite database.
  • With the right plugins we are able to import SQL data (or even JSON structure) into the SQLite database of a device with Ionic.
Although the Ionic Storage package is great to store almost any kind of data, many of the readers wrote they are using MySQL on the backend side and need some more equivalent storage inside their Ionic app.

@schlimmson: How to Use @Ionicframework SQLite Queries & Pre-Populated Database #angular @JavaScriptDaily
Although the Ionic Storage package is great to store almost any kind of data, many of the readers wrote they are using MySQL on the backend side and need some more equivalent storage inside their Ionic app.
In this post we will see how to easily import SQL data into our Ionic app, and how to work with queries to retrieve or modify our stored data!
Note: If you have some sort of MySQL database you should still work on a REST API to deliver the data and don’t work directly on the database.
We start with a blank Ionic app and install the Cordova SQLite plugin to access the database. Additional we add the SQLite Porter plugin as well as the according Ionic Native NPM packages so we can populated our SQL database from e.g. a given SQL dump. Go ahead and run:
We also create a provider for all of our database interaction right here.
As said before we want to fill our database with some initial values. You can do this of course with the standard SQLite wrapper but you would either have to prepare each statement accordingly or split up your SQL dump into the right format, which is sometimes not a good idea.
The SQLite Porter plugin would also allow to import JSON data, but here we stick to SQL.
In our case it’s enough to have a SQL dump like…
How to Use Ionic SQLite Queries & Pre-Populated Database