Giter VIP home page Giter VIP logo

pure-js-websql's Introduction

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.

pure-js-websql's People

Contributors

yradtsevich avatar mateuszjarzewski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.