I am trying to learn how to use sql.js from here. https://sql.js.org/#/
I am following there first html example and I keep coming across errors just trying to run this.
I installed sql.js using npm install sql.js
I took the dist folder from the sql.js install and put it into the test folder where the index.html is.
I used there example code and tried open it in a browser but I am faced with: sql-wasm.js:167 Fetch API cannot load file:///C:/dist/sql-wasm.wasm. URL scheme "file" is not supported.
Code:
<meta charset="utf8" />
<html>
  <script src='C:\\Users\\Rocko\\Documents\\scripts\\AAOA\\nodetest\\dist\\sql-wasm.js'></script>
  <script>
    config = {
      locateFile: filename => `/dist/${filename}`
    }
    // The `initSqlJs` function is globally provided by all of the main dist files if loaded in the browser.
    // We must specify this locateFile function if we are loading a wasm file from anywhere other than the current html page's folder.
    initSqlJs(config).then(function(SQL){
      //Create the database
      const db = new SQL.Database();
      // Run a query without reading the results
      db.run("CREATE TABLE test (col1, col2);");
      // Insert two rows: (1,111) and (2,222)
      db.run("INSERT INTO test VALUES (?,?), (?,?)", [1,111,2,222]);
      // Prepare a statement
      const stmt = db.prepare("SELECT * FROM test WHERE col1 BETWEEN $start AND $end");
      stmt.getAsObject({$start:1, $end:1}); // {col1:1, col2:111}
      // Bind new values
      stmt.bind({$start:1, $end:2});
      while(stmt.step()) { //
        const row = stmt.getAsObject();
        console.log('Here is a row: ' + JSON.stringify(row));
      }
    });
  </script>
  <body>
    Output is in Javascript console
  </body>
</html>
I have been trying to have my test webapp read my sqlite file for about 2 weeks now and I have been trying to follow what people have suggested. This is the latest suggestion and so I am trying to learn this but I can't even get the basic example done.
Any ideas would be appreciated.
Thanks


 
    