Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript and Sqlite

I am creating an app using HTML5 and Javascript. This app will be compatible with Windows and iOS 6 (iPad). I need a local database access using javascript. This is a pure offline ap with no server side involved.

My dilemma is -

  1. WebSQL is not supported anymore by W3C.

  2. IndexedDB works with Firefox but not with iOS6.

  3. Most importantly, I want to avoid HTML5 Local database storage as it cleans data whenever history is cleared.

I would like to have a durable database locally for the app, something like SQLite. Is it possible to access SQLite using pure javascript, so that it will work with Firefox on Windows and also on iPad.

EDIT: The app will not be run from the browser in iPad (iOS6). Rather the app will be packaged into ipa file and installed in the iPad device.

like image 836
user32262 Avatar asked Jan 15 '13 09:01

user32262


3 Answers

What you're looking for is a polyfill.

According to HTML5 Please, IndexedDB Polyfill implements the IndexedDB APIs over WebSQL. (The author of the polyfill also wrote an article on Mozilla Hacks about it.)

Facebook also as a polyfill. According to this pull request (to another project), Parashuram Narasimhan, the author of the first polyfill, seems to prefer the Facebook polyfill and is considering retiring his own project. (But then again, the Facebook repo looks like a one-time code dump and may not have any ongoing development.)

like image 137
Jeffery To Avatar answered Nov 18 '22 23:11

Jeffery To


There are some points to note.

  1. Its a pure client side app.
  2. Not using webstorage (local and session)

The options left are using webSQL, IndexedDB, Third-party framework or custom solutions.

webSQL :- Support is limited to webkit browsers and w3c declared its dead. Browser support

IndexedDB :- Supports in IE10, chrome and Firefox. Browser support. Not supported in older versions of IE.

Third-party framework :- sequelsphere is a platform independent solution to address this issue. It is a RDMS written entirly in javascript and make use of webSQL or IndexedDB.

custom solutions :- Supporting both IndexedDB and WebSQL on a cross platform web app like this tutorial, we can create our custom cross-browser db solutions or may use lawnchair like json storage options.

like image 25
Praveen Vijayan Avatar answered Nov 18 '22 21:11

Praveen Vijayan


We had same issue and got answered on this thread.

Lawnchair is a good choice if you need a single table DB - we had requirement of multiple tables, so have developed own wrapper.

Create a web app using HTML-5 and JavaScript, so that it can work for both desktop browser and iPad. Make it hybrid using PhoneGap for making it iPad's native app.

like image 1
Taha Avatar answered Nov 18 '22 23:11

Taha