Published
Edited
Apr 24, 2018
5 forks
2 stars
Insert cell
Insert cell
Insert cell
db = window.openDatabase("Grades", "1.0", "grades", 4000000)
Insert cell
Insert cell
db.transaction(function (tx) {
tx.executeSql('CREATE TABLE bar (id INT PRIMARY KEY, Name TEXT,Score INTEGER)');
})
Insert cell
Insert cell
db.transaction(function (tx) {
tx.executeSql('INSERT INTO bar (id,Name,Score) VALUES (1,"Kimon",60)');
tx.executeSql('INSERT INTO bar (id,Name,Score) VALUES (2,"Joe",99)');
tx.executeSql('INSERT INTO bar (id,Name,Score) VALUES (3,"Janos",100)');
})
Insert cell
Insert cell
runQuery = (dbh,query,param,cb) => {
dbh.transaction(function (tx) {
tx.executeSql(query,param,cb);
})
}
Insert cell
Insert cell
runQuery(db,'INSERT INTO bar (id, Name) VALUES (3,"Ed")')
Insert cell
runQuery(db,'INSERT INTO bar (id, Name, Score) VALUES (4,"Ting",80)')
Insert cell
runQuery(db,'DELETE FROM bar WHERE Name = "Kimon"')
Insert cell
runQuery(db,'UPDATE bar SET Score=99 WHERE Name="Ed"')
Insert cell
Insert cell
runQuery(db,'SELECT * FROM bar',[], function (tx,results) {
var len = results.rows.length;
var i;
console.log(len);
for (i = 0; i < len; i++) {
console.log(results.rows.item(i).Name);
}
})
Insert cell
Insert cell
{
return("Exercise 1 Code")
}
Insert cell
Insert cell
{
return("Exercise 2 Code");
}
Insert cell
Insert cell
{
return("Exercise 3 Code");
}
Insert cell
Insert cell
{
return("Exercise 4a Code");
}
Insert cell
{
return("Exercise 4b Code");
}
Insert cell
{
return("Exercise 4c Code");
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more