Mobile sqlite help

thank you george. I’ll try to add it manually with javascript. We already have a powerful feature like flow. I guess I can handle this by using this and javascript functions. I may just need a simple function that I can fetch sqlite rows in the wappler repeater. Is there an example or can you give me?

I have created an array called “arr1” in wappler and if I can set the incoming data from sqlite to arr1, then will be ok …

image

function getcontact(phone) {
    db.transaction(function (tx) {
        var query = "SELECT name FROM contacts WHERE phone = ?";
        tx.executeSql(query, [phone], function (tx, resultSet) {
            for (var x = 0; x < resultSet.rows.length; x++) {
                console.log("getcontactname item: " + resultSet.rows.item(x).name);
            }
        },
            function (tx, error) {
                console.log('SELECT error: ' + error.message);
            });
    }, function (error) {
        console.log('transaction error: ' + error.message);
    }, function () {
        console.log('transaction ok');
    });
}

Yes something like this should do, you just need to assign the js variable to app connect.

Are you using further Cordova SQLite addon?

1 Like

Yes that is the one. We will be using the same for the app flow database actions.

1 Like

Hey @George Any update on timing for this? I am deciding how to allow for a mobile app offline experience (data and images) and using flows and sqlite would certainly be a nice option. I’m envisioning updating a local sqlite db with the most recent data from standard server connects when connected to the network, and then using the local db from that point forward.

Also seems like sqlite could be added as a front end data source for repeats, etc. much like the json datasource component.

In my experience during this time, I think it would be much better to have a different solution instead of SQLite.
Maybe PouchDB - CouchDB

Agreed, but since the team has already done half of this (adding sqlite to the project settings of a mobile app) it seems like it should be turned into something useable.

Well the SQLite is perfect for mobile apps and with Cordova it has a nice native integration.

We are indeed half way of integrating it, so you can do all database queries and updates directly client side in a flow action.

Hope to add that in the next weeks.

New Year’s seems like a great time to finish this up. :wink:

3 Likes

We do have a bit of dilemma…

Seems more and more Cordova plugins are running behind and aren’t managed actively.

So the Cordova SQlite plugin is missing Electron and other features integrations…

While the new Capacitor and their plugins system is booming and growing fast.

And their community driven Capacitor Plugin for Sqlite is much richer and supports Electron as well.

So should we be supporting the old Cordova plugins and eventually move to Capacitor as well and go and support their plugins? But then you will also have to convert from old Cordova plugins to new capacitors…

Or should we just add Capacitor and support for its plugins directly …

Maybe you can try capacitor and share your experiences with it.

Handy list of incompatible plugins here:

Doesn’t look like it would be too difficult to switch over. Plenty of guides available, and as long as you’re not implementing a lot of Cordova plugins should be very easy to convert across…

:slight_smile:

1 Like

@George

I had a chance to test this for a very long time. Definitely capacitor should be used directly instead of cordova. :+1:

Also … you should also consider adding PouchDB/CouchDB.

2 Likes

I’ve never used capacitor, so today I copied a working cordova bs5 project over and tried it out.

It only took a few minutes to get capacitor added and a build running in a simulator through xcode.

My current routing does not work, but I’m assuming that can be solved (Does anybody already know the syntax for using a browser.goto to navigate to different views?)

So my initial results are good! It sure seems to be a better place to concentrate efforts.

1 Like

Have written a quick guide on developing with Capacitor and Wappler:

:wink:

Now you can use SQLite for your mobile and desktop projects: Using Local Databases in Mobile and Desktop apps

This topic was automatically closed after 2 days. New replies are no longer allowed.