Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite synchronous

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

like image 771
Vignesh T.V. Avatar asked Mar 26 '13 13:03

Vignesh T.V.


People also ask

What is a SQLite PRAGMA?

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.

Can SQLite handle concurrency?

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.

Is SQLite good for caching?

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.


2 Answers

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 :)

like image 143
Reinstate Monica Cellio Avatar answered Oct 22 '22 21:10

Reinstate Monica Cellio


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.

like image 32
Simply Innovative Avatar answered Oct 22 '22 23:10

Simply Innovative