Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phonegap: WebSql or SqLite?

I have been working with phonegap for little time, and i'm having some trouble with the concept of storage in it.

So, the documentation states that there is this database that you can open, and it is a SQLite implementation."window.openDatabase returns a new Database object.

This method will create a new SQL Lite Database and return a Database object. Use the Database Object to manipulate the data." http://docs.phonegap.com/en/2.2.0/cordova_storage_storage.md.html#Database I'm using it at my webApp right now:

var myBuggedDb = window.openDatabase(shortName, version, displayName,maxSize);

It works like a charm. I can use it to make queries, from selects to delete's. All good, right? But when i inspect and debug my code, i see that what is created is a WebSql database. I have also consulted a lot of blogs, wiki's and other places to get more info about the topic. It seens a lot of people make a mess out of both techs. Phonegap Plugin page doesn't even have the sqlite plugin.

And now, we are going to change our app so it takes from a localStorage a JSON object and converts it. I want to insert it into our database. But now i'm confused, i don't know if this is webSql or SQLite. Could someone clarify? Will it work as a SQLite or as a WebSql after all, on the device?

EDIT: If you are looking for this question in the future, tread carefully: The technologies have changed a lot, indexedDB support is growing, there are many other options as well, like Lawchair and such. Do a little research before using anything!

like image 978
Malavos Avatar asked Nov 21 '13 13:11

Malavos


2 Answers

HTML 5 has this implementation of databases and the implementation is done by embedding Sql Lite database in to browser.

Browser's like chrome and Safari have there implementation of Html5 databases implemented using sqlLite termed as websql but when I was in touch, Mozilla wasn't implementing the Websql instead they were implementing Indexed DB.

Better option I think is to use Backbone.js or Lawnchair although internally both of them use websql but the API's wrap everything for you.

Hope this helps.

like image 119
varun Avatar answered Sep 28 '22 03:09

varun


I would suggest to go with WebSQL. The detailed reason is as mentioned below:

Lets go ahead and consider the 3 major platforms that you will go with using PhoneGap:

  • IOS: WebSQL - SUPPORTED SQLite - PARTIALLY SUPPORTED
  • Android: WebSQL - SUPPORTED SQLite - FULLY SUPPORTED
  • Windows: WebSQL - NOT SUPPORTED SQLite - NOT SUPPORTED

So ideally it goes like this - You have Windows over which you wrap up a WebSQL Plugin [unreliable] above which you wrap up a SQLite Plugin [highly unreliable].

Hence - It's now your call. Even if you are making phonegap Apps they are mean to be fast and creating layers of one stack over another will definitely make it slow.

like image 35
Ankit Tanna Avatar answered Sep 28 '22 02:09

Ankit Tanna