| 21 | }); |
| 22 | |
| 23 | const createWebSQLDatabase = () => { |
| 24 | openDatabase( |
| 25 | // Name |
| 26 | 'mydatabase', |
| 27 | // Version |
| 28 | '', |
| 29 | // Display name |
| 30 | 'mydatabase', |
| 31 | // Estimated size |
| 32 | 1024, |
| 33 | // Creation callback |
| 34 | function (_db) { |
| 35 | db = _db; |
| 36 | db.transaction( |
| 37 | // Transaction callback |
| 38 | function (tx) { |
| 39 | // Execute SQL statement |
| 40 | tx.executeSql( |
| 41 | // SQL statement |
| 42 | 'create table rainstorms (mood text, severity int)', |
| 43 | // Arguments |
| 44 | [], |
| 45 | // Success callback |
| 46 | function () { |
| 47 | // Execute SQL statement |
| 48 | tx.executeSql( |
| 49 | // SQL statement |
| 50 | "insert into rainstorms values ('somber', 6), ('rainy', 8), ('stormy', 2)" |
| 51 | ); |
| 52 | } |
| 53 | ); |
| 54 | }, |
| 55 | // Error callback |
| 56 | function (err) { |
| 57 | console.error(err.name, err.message); |
| 58 | pre.textContent = `${err.name}: ${err.message}.`; |
| 59 | }, |
| 60 | // Success callback); |
| 61 | function () { |
| 62 | console.log('Transaction succeeded!'); |
| 63 | } |
| 64 | ); |
| 65 | } |
| 66 | ); |
| 67 | pre.textContent = 'Web SQL database created.'; |
| 68 | }; |
| 69 | |
| 70 | const createSQLiteDatabase = () => { |
| 71 | worker.postMessage({ |