Skip to content
100% JavaScript implementation of Web SQL API
JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
js
test
README.md

README.md

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.

Something went wrong with that request. Please try again.