WebDB.js

Note: This plugin may not work in Firefox and Internet Explorer as these browsers do not support WebSQL (, God knows why).

Download

A javascript and jQuery plugin which let's you play with WebSQL feature of HTML5 easily. You can create Web Databases and then do anything with them.

Using WebDB.js is simple like hell:

1 - Create a connection

var db = $.webdb(); var con = db.connect({ shortName : "MyDB", version : "1.0", displayName : "My DB" });

In above code, we saved the new connection, we made to database, in con variable for future refference.

2 - Simply Run a query

con.run({ query:"CREATE TABLE IF NOT EXISTS notes (id int(11) NOT NULL, title varchar(255) NOT NULL, text text NOT NULL)", values:null, onSuccess:function(tx,r) { alert('Table created.'); }, onError:function(tx,err) { alert("Error in table creation!"); });

We used the previously created con object, called it's method run() and passed the query we want to run.

That's it, Let's show you a demo




This demo is a simple application that saves your notes with their title. You can even edit them later. This is completely based on WebSQL database. Only available to you so whatever you do, nobody else would see it. And it is available to unless you delete it yourself.

Docs

Methods:

$.webdb() has one method; connect(). connect() accepts 1 objects having four options shortName, version, displayName, maxSize.

Calling connect() return the object which has method run().

run() accepts one object having four options query, values, onSuccess and onError.

Options details:

Option Value Type Detail Default
connect()
shortName String Short name for the database. MyDB
version Float Version of database you want to open. 1.0
displayName String Database name that will be shown to you in developer console. MyBD
maxSize Integer Max size of the database. 65336
run()
query String SQL query you want to run. null
values String Values for that SQL query. null
onSuccess Function Function called on success of query. Will be called with passing two parameters. First the SQL transaction refference and second the query results. function(t,r) { alert("Success"); }
onError Function Function called on failure of query. Will be called with passing two parameters. First the SQL transaction refference and second the error object. function(t,err) { alert("Error!"); }