Skip to content

100% JavaScript implementation of Web SQL API

Notifications You must be signed in to change notification settings

samarthsaxena/pure-js-websql

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

100% JavaScript implementation of Web SQL API

Pure-JS-WebSQL is an implementation of Web SQL Database API in pure JavaScript.
The implementation provides a glue between Web SQL Database API and SQL.js (SQLite port to JavaScript). The data between sessions is stored in the localStorage.

Demo

Pure-JS-WebSQL Demo. It should work in any Gecko- or WebKit-based browser.

Usage

<html>
<head>
   <!--Note: GitHub does not allow linking to .js files on their servers anymore.
       You must download two following .js files and host them on your own server. -->
   <script src='https://raw.github.com/kripken/sql.js/master/js/sql.js'></script>
   <script src='https://raw.github.com/yradtsevich/pure-js-websql/master/js/purejswebsql.js'></script>
   <script>
      openDatabase = purejsOpenDatabase;

      // now you may use Web SQL API as if it is supported by your browser:
      var db = openDatabase('mydb', '1.0', 'my first database', 2 * 1024 * 1024);
      db.transaction(function (tx) {
	     tx.executeSql('DROP TABLE IF EXISTS foo');
         tx.executeSql('CREATE TABLE IF NOT EXISTS foo (id unique, text)');
         tx.executeSql('INSERT INTO foo (id, text) VALUES (?, ?)', [1, 'synergies']);
         tx.executeSql('SELECT * from foo', [], function(tx, result) {
            alert('id = ' + result.rows.item(0).id + ', text = ' + result.rows.item(0).text)
         });
      });
   </script>
</head>
<html>

License

Pure-JS-WebSQL is released under the MIT license.

About

100% JavaScript implementation of Web SQL API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%