Welcome Guest! (App Version 3.1)

websitnero logo name

Web SQL

Using Web SQL in HTML5

Web SQL is an API for storing data in DataBases just like Indexed DB. The W3C Working Group later ceased working on this specification due to lack of independent implementations meaning lack of any database implementation while using Web SQL. Currently, it only works for SQLite database but not for others. Mozilla Corporation said it was not going to provide browser support for this feature, and later this feature was Deprecated. Now, in preferance to it Indexed DB is being developed and accepted by all parties.

Example

<body>

<p id="para1"></p>

<script>

var myDB = openDatabase('db_hero', '1.0', 'I like this database', 2 * 1024 * 1024);

myDB.transaction(function (tx) {
  tx.executeSql('CREATE TABLE IF NOT EXISTS peoples (id INTEGER PRIMARY KEY ASC, name TEXT, age TEXT)');
  tx.executeSql('INSERT INTO peoples (id, name, age) VALUES (1, "Peter", 29)');
  tx.executeSql('INSERT INTO peoples (id, name, age) VALUES (2, "Jack", 31)');
  tx.executeSql('INSERT INTO peoples (id, name, age) VALUES (3, "Lila", 27)');
});

myDB.transaction(function (tx) {

  tx.executeSql(

    //1st parameter
    'SELECT * FROM peoples', 

    //2nd parameter
    [], 

    //3rd parameter
    function (tx, results) {
      for (i = 0; i < results.rows.length; i++){
        var row =  results.rows.item(i);
        var x = document.getElementById('para1');
        x.innerHTML += row.id + " " + row.name + " " + row. age + "<br>"; 
      }
    },

    //4th parameter
    null
  );
});
	
</script>

</body>
WebsiteNero is highly optimized for learning various website developing technlogies. We try our best to add maximum modules and examples to help learn the concepts clearly and vividly. We try to present all content and examples as simple as we can removing any complexity to hurdle easy understanding. We try best provide you with worthful content, but we cannot guarantee full correctness of all the content on this site. While using this website, you agree to have read and accepted all our terms of use and conditions, cookie, and privacy policy. Copyright, 2013-2018 by websitenero.com. All Rights Reserved.