Search code examples
databasesqlitecordovaweb-sql

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!


Solution

  • 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.