

Tx.executeSql('INSERT INTO LOGS (id,log) VALUES (?, ?'), We can pass dynamic values while creating entering as follows − Tx.executeSql('INSERT INTO LOGS (id, log) VALUES (2, "logmsg")') Tx.executeSql('INSERT INTO LOGS (id, log) VALUES (1, "foobar")') To create enteries into the table we add simple SQL query in the above example as follows − The above query will create a table called LOGS in 'mydb' database. Tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, log)') This function needs a single argument, which is a function that takes care of actually executing the query as follows − To execute a query you use the ansaction() function. Without this feature, however, the databases are still being created on the fly and correctly versioned. The Core Methods There are following three core methods defined in the spec that I am going to cover in this tutorial openDatabase This method creates the database object either using existing database or creating new one. The last and 5th argument, creation callback will be called if the database is being created. Web SQL Database will work in latest version of Safari, Chrome and Opera. The above method took the following five parameters −
#Web slices tutorial code
To create and open a database, use the following code − The openDatabase method takes care of opening a database if it already exists, this method will create it if it already does not exist. Transaction − This method gives us the ability to control a transaction and performing either commit or rollback based on the situation.ĮxecuteSql − This method is used to execute actual SQL query. OpenDatabase − This method creates the database object either using existing database or creating new one. There are following three core methods defined in the spec that I am going to cover in this tutorial − Web SQL Database will work in latest version of Safari, Chrome and Opera. If you still want to have a session with SQL then, you can go through our SQL Tutorial. I'm assuming you are a great web developer and if that is the case then no doubt, you would be well aware of SQL and RDBMS concepts. The Web SQL Database API isn't actually part of the HTML5 specification but it is a separate specification which introduces a set of APIs to manipulate client-side databases using SQL.
