Skip to content

Using Local Databases in Mobile and Desktop apps

Original guide · All levels

Intro You can use local SQLite database for your mobile and desktop apps. The database will be created locally on the users device initially on app start. The database will be created as defined in th

You can use local SQLite database for your mobile and desktop apps. The database will be created locally on the users device initially on app start. The database will be created as defined in the database manager in Wappler. That’s a great way to allow users to store, manage and work with dynamic data locally, without an internet connection.

Note the Capacitor SQLite Connector is a beta extension now to let your try new functionality first. So make sure you have enabled the experimental options and have enabled the Beta extensions channel in your Wappler Settings.

We start with creating a standard blank mobile project in Wappler. It can be Bootstrap or Framework 7 based, for this simple tutorial we select Bootstrap:

Add a name for the project, select a local folder for it and make sure you selected Capacitor as a runtime:

Section titled “Add a name for the project, select a local folder for it and make sure you selected Capacitor as a runtime:”

Once you create the project, a system check will be required. Click yes and the system check will be performed:

The local SQLite database on your users devices will be created based on how it’s defined in Wappler’s Database Manager.

The first step is to create the database. Open the Database Manager and click the Create New Connection button:

Add a name for your database connection and click the create new database file button:

Section titled “Add a name for your database connection and click the create new database file button:”

Add a name for the database file and save it in the root folder of your project:

Section titled “Add a name for the database file and save it in the root folder of your project:”

And you are done. Your database has been successfully created.
Note that you can create multiple databases for your project if needed.

Let’s continue with creating the database tables. Right click Tables and select New Table:

For this tutorial we create a simple table called users and add 3 additional columns next to the id column - first_name, last_name and email. This table will store some data about our users. Click the apply changes button:

Add a description for the changes you are applying and click OK:

Section titled “Add a description for the changes you are applying and click OK:”

If you want to add some predefined data in your database table(s), that will be also added on your users devices, when they run the app, you can do it in the Database Manager. This is optional and not a mandatory step - you can also just provide your users with an empty database table.

Right click and select View/Edit Data:

Click Add New in order to add a new record in your table:

Section titled “Click Add New in order to add a new record in your table:”

Add as many records as you need and click Save:

Section titled “Add as many records as you need and click Save:”

So we keep the first option enabled, in order to transfer the data we entered to the users’ devices database:

Section titled “So we keep the first option enabled, in order to transfer the data we entered to the users’ devices database:”

A dialog with two options appears.
Keep as Changes - will keep your data as a database change and will transfer the data you just added to your users devices on the first run.
Keep Same IDs - to always use the same IDs for the database changes.

So we keep the first option enabled, in order to transfer the data we entered to the users’ devices database:

You can see the data we entered in the database:

Section titled “You can see the data we entered in the database:”

We close the database manager for now and open the index.html page.
The next thing we are going to explain is how to use the dynamic data on your pages.

First let’s see how to display the dynamic data on your app’s pages.
Add a new component:

Open the Database Actions menu and select Database Query:

Section titled “Open the Database Actions menu and select Database Query:”

Select your database connection and open the Query Builder:

Section titled “Select your database connection and open the Query Builder:”

The Query Builder dialog is the same as in Server Connect.
We open the tables menu and select our users table:

We add the columns which we want to output and click Ok:

Section titled “We add the columns which we want to output and click Ok:”

Then click Save to add the flow on the page:

Section titled “Then click Save to add the flow on the page:”

We will use this flow to display the data on the page, so we need it to auto run on app load. So we check the Auto Run checkbox:

You can display the data on the page in any repeat region or any structure you like. We will display it in a dynamic table. Add new component:

Then select the data to be used for the dynamic table:

Section titled “Then select the data to be used for the dynamic table:”

Under the page flow we created, select data > query:

Section titled “Under the page flow we created, select data > query:”

Setup your dynamic table look and field and click OK:

Section titled “Setup your dynamic table look and field and click OK:”

And you are done. You can see the data rendered in our app:

Section titled “And you are done. You can see the data rendered in our app:”

You can also insert data in the local SQLite database, in a way very similar to how you do this in Server Connect.

We created a very basic form, containing 3 inputs - first_name, last_name and email. The form should not be a server connect form, as we are not using any server actions here:

The form also contains a button. Note that this is not a submit button, but a regular button:

Section titled “The form also contains a button. Note that this is not a submit button, but a regular button:”

Right click app structure and add a new page flow:

Section titled “Right click app structure and add a new page flow:”

Similar to server connect insert step, we need to select the table where we want to insert the data:

Section titled “Similar to server connect insert step, we need to select the table where we want to insert the data:”

Click the dynamic data picker to select the data for the first name column:

Section titled “Click the dynamic data picker to select the data for the first name column:”

We select the first_name field from our form on the page:

Section titled “We select the first_name field from our form on the page:”

We do the same for the rest of the fields:

Section titled “We do the same for the rest of the fields:”

Then we want to reload the dynamic data on the page, after we insert the new records, so we add a new step:

Section titled “Then we want to reload the dynamic data on the page, after we insert the new records, so we add a new step:”

We select to run the flow, used to display the data on the page:

Section titled “We select to run the flow, used to display the data on the page:”

Now we need to run this insert flow by clicking the button. Select the button:

Section titled “Now we need to run this insert flow by clicking the button. Select the button:”

We select to run the insert data flow we created:

Section titled “We select to run the insert data flow we created:”

and that’s it. You can check the results:

Section titled “and that’s it. You can check the results:”

and that’s it. You can check the results:

After we tested our app using the default platform - web, then we can add the platform we need to build our app for - Android and iOS (for mobile apps) or Electron (for desktop apps).

To add a platform open the platforms menu and select one. In this example we will show you how to do this for Electron, as it also has some specific requirements for Windows computers.

Windows only:
Make sure to download and install node.js from the official website https://nodejs.org/ and when installing it, make sure to enable installation of the optional tools for compiling native modules:

The steps below are valid for all OS. To add Electron to your project, open the platforms menu:

Section titled “The steps below are valid for all OS. To add Electron to your project, open the platforms menu:”

The steps below are valid for all OS.
To add Electron to your project, open the platforms menu:

You will see two confirmation popups appearing, click Yes for both, so all the required files can be installed in your project:


You will see a loader, showing the status of installation and a successful message when the installation finishes:


The following step is required for Electron based projects only.
Once you add Electron to your project, make sure to open and close the Flow we already created, so that it can add electron specific files to your projects:


And finally we can preview this simple app:

Section titled “And finally we can preview this simple app:”

And finally we can preview this simple app:

You can see our dynamic data displayed on the page in a table:

Section titled “You can see our dynamic data displayed on the page in a table:”