]> git.ardis.lu - sheets-db/commitdiff
Update demo to use SQLite binary instead of query
authorArdis Lu <ardisglu@gmail.com>
Sun, 28 Nov 2021 07:21:26 +0000 (23:21 -0800)
committerArdis Lu <ardisglu@gmail.com>
Sun, 28 Nov 2021 07:21:26 +0000 (23:21 -0800)
demo/index.html

index 2b05c422649098b1d3b3e2fa57c6bf3180388796..aaf38c059208a81904ba9b6f40028ccdeffb4ee2 100644 (file)
     document.getElementById('execute').addEventListener('click', () => executeSQL(editor.getValue()));
 
     /** Globals related to the initial data table */
-    const queryPromise = fetch('https://sheets-db-sql.ardis.lu/file/sheets-db/generateDatabaseQuery.sql').then(response => response.text()); // Fetch from CDN mapped to Backblaze
-    // const queryPromise = fetch('https://f002.backblazeb2.com/file/sheets-db/generateDatabaseQuery.sql').then(response => response.text()); // Fetch from Backblaze origin
-    // const queryPromise = fetch('http://sheets-db-sql.ardis.lu/sheets-db/generateDatabaseQuery.sql').then(response => response.text()); // Fetch from CDN mapped to Google Storage
-    // const queryPromise = fetch('https://storage.googleapis.com/sheets-db/generateDatabaseQuery.sql').then(response => response.text()); // Fetch from Google Storage origin
-    // const queryPromise = fetch('/generateDatabaseQuery.sql').then(response => response.text()); // Fetch from local
+    const databasePromise = fetch('https://sheets-db-sql.ardis.lu/file/sheets-db/database.sqlite3').then(response => response.arrayBuffer()); // Fetch from CDN mapped to Backblaze
+    // const databasePromise = fetch('https://f002.backblazeb2.com/file/sheets-db/database.sqlite3').then(response => response.arrayBuffer()); // Fetch from Backblaze origin
+    // const databasePromise = fetch('http://sheets-db-sql.ardis.lu/sheets-db/database.sqlite3').then(response => response.arrayBuffer()); // Fetch from CDN mapped to Google Storage
+    // const databasePromise = fetch('https://storage.googleapis.com/sheets-db/database.sqlite3').then(response => response.arrayBuffer()); // Fetch from Google Storage origin
+    // const databasePromise = fetch('/database.sqlite3').then(response => response.arrayBuffer()); // Fetch from local
 
     /** Globals related to SQL.js */
     const sqlPromise = initSqlJs({
     let db;
 
     (async () => {
-      const data = await Promise.all([queryPromise, sqlPromise]);
-      const [generateDatabaseQuery, SQL] = data;
+      const data = await Promise.all([databasePromise, sqlPromise]);
+      const [database, SQL] = data;
 
-      db = new SQL.Database();
-      db.run(generateDatabaseQuery);
+      db = new SQL.Database(new Uint8Array(database));
     })();
   </script>
 </body>
This page took 0.035061 seconds and 4 git commands to generate.