You can use an export to json / import to database. I have an example below that does not specify a path (easily fixed ?) but not sure what the proper process is for pasting or attaching code to these replies. Someone let me know if just inserting in the body of the reply as below is regarded as bad practice.
Thanks,
Jim
var startTime;
btnSQLExport.onclick = function() {
var DB = SqlOpenDatabase("fixit.db");
if(typeof(DB)=="undefined") {
NSB.MsgBox("Database not found...");
} else {
NSB.ShowProgress("Exporting database...");
DBjson=SQLExport(DB, "fixit.db" , exportComplete);
}
};
function exportComplete() {
NSB.ShowProgress(false);
txtMessage.value=JSON.stringify(DBjson);
}
//<<<<<< Import <<<<<
btnSQLImport.onclick = function() {
startTime=SysInfo(10);
if(typeof(DBjson)=="undefined") {
NSB.MsgBox("Use the SQLExport button to create a data to import");
} else {
SQLImport(DBjson, DB, importComplete);
}
};
function importComplete(s) {
console.log("importComplete() called. " + s);
//refresh the selection
sqlList= new Array(["SELECT * from repairsTbl ORDER BY locn_id;" , dataHandler]);
Sql(DB, sqlList);
txtMessage.value="Import completed.";
}
function dataHandler(transaction, results) {
//Called On completion of Sql command
DBRecords = results;
txtMessage.value = "Recs created: " + DBRecords.rows.length + " in " + (SysInfo(10)-startTime) + " milliseconds.";
}
Button3.onclick=function(){
function download(content, fileName, contentType) {
var a = document.createElement("a");
var file = new Blob([content], {type: contentType});
a.href = URL.createObjectURL(file);
a.download = fileName;
a.click();
}
var jsonData = JSON.stringify(DBjson);
download(jsonData, 'json.txt', 'text/plain');
}