i have been using sqlite, phonegap, javascript and i m in need of fetching information from the sqlite db.
I am able to fetch all info i need, insert, update, etc.
The problem is javascript works asynchronously. That is it is processing all other succeeding statements before all the necessary info from database gets fetched.
i have tried using callbacks all along and i am tired of it since there are difficulty in using loops. (not able to use sqlite queries within loops since loop gets iterated before the current sqlquery gets processed which is not what i want)
is it possible to do these db operations synchronously?
UPDATE Found out a new solution from here: webkit executesql sentence and loop problem
The PRAGMA statement is an SQL extension specific to SQLite and used to modify the operation of the SQLite library or to query the SQLite library for internal (non-table) data.
SQLite does support multiple concurrent connections, and therefore it can be used with a multi-threaded or multi-process application. The catch is that when SQLite opens a write transaction, it will lock all the tables.
Many applications use SQLite as a cache of relevant content from an enterprise RDBMS. This reduces latency, since most queries now occur against the local cache and avoid a network round-trip. It also reduces the load on the network and on the central database server.
No, but there's a library that may help...
http://html5sql.com/
I've just started using it myself and it allows you to execute multiple or single SQL requests, with 1 callback. It may be just what you need :)
You can use Siminov Framework. It allows you to make both Synchronous/Asynchronous calls to the native SQLite database. It supports most of the Hybrid Frameworks such as (Cordova, React Native, Xamarin)
However if you are building a Hybrid Apps using JavaScript, then I would recommend to use Asynchronous calls because it has a performance advantage over Synchronous calls.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With