Cannot delete rows in AlaSQL table

29 Views Asked by At

I'm new to AlaSQL, everything works fine but when I try to delete rows I run into an error message, I try this:

          alasql.options.autocommit = true;
          alasql("CREATE localStorage DATABASE IF NOT EXISTS lsdb");
          alasql("ATTACH localStorage DATABASE lsdb AS db");
          alasql("CREATE TABLE IF NOT EXISTS db.people (Id INT,FirstName STRING,LastName STRING);");
          alasql("INSERT INTO db.people VALUES (1,'Peter','Peterson'), (2,'Eric','Ericson'), (3,'John','Johnson');");
          alasql("DELETE FROM db.people");
          alasql("SELECT * INTO HTML('#res',{headers:true}) FROM db.people;");

I get this error:

enter image description here

What am I missing?

1

There are 1 best solutions below

0
On

Made some changes to the code and this works:

      alasql.options.autocommit = true;
      alasql("CREATE localStorage DATABASE IF NOT EXISTS lsdb");
      alasql("ATTACH localStorage DATABASE lsdb");
      alasql("USE lsdb");
      alasql("CREATE TABLE IF NOT EXISTS people (Id INT,FirstName STRING,LastName STRING)");
      alasql("INSERT INTO people VALUES (1,'Peter','Peterson'), (2,'Eric','Ericson'), (3,'John','Johnson')");
      alasql("DELETE FROM people");
      alasql("SELECT * INTO HTML('#res',{headers:true}) FROM people;");