Quesions about SQLite databases

  1. If all I’m doing is making a SQLite database app that runs on a browser, do I need to put anything in “extra files”?

  2. In the “manifest” there is a section that begins with a { and ends with a } with many subsections in it. Does this all have to be filled in?

Should this:
C:\Users\tonyA\Documents\A_NSBasic Projects\MyApp\MyApp.db,DB,loadComplete,NSB.overwriteNever
Go ahead of the {, within the { } section, or after the }?

Thanks.

  1. If the SQLite database is being created on the device, you do not have to put anything into extrafiles. That’s for including a database with your app.

  2. manifest is used for PWA apps. See the docs here.

I’m not sure where you intend to put that final line, but it should not have " **C:\Users\tonyA\Documents\A_NSBasic Projects\MyApp* in it - that path will not work at runtime.

I’m confused then.
How does the app know where the database is when you run the app in a browser for testing?
The Persisting Updates to the Database section says we should use
‘mydb.db,dbObj,callBackMethod,NSB.overwriteIfVersionDifferent’. or something similar.

Do I open the database in the code itself?
Thanks.

Have a look at the Northwind sample - it imports a database and populates a grid from it.

Here’s how it opens the database:

JavaScript:

function loadGrid(e) {
  console.log("loadGrid called: "  +  e);
  NSB.ShowProgress("Loading grid with customers...");
  DB=SqlOpenDatabase("Northwind.db");
  s= new Array(["Select * from Customers ORDER BY CustomerID;" , dataHandler]);
  Sql(DB,s);
}

BASIC:

Sub loadGrid(e)
  console.log("loadGrid called: " & e)
  NSB.ShowProgress("Loading grid with customers...")
  DB=SqlOpenDatabase("Northwind.db")
  s=Array(["Select * from Customers ORDER BY CustomerID;", dataHandler])
  Sql(DB,s)
End Sub