Setup:
Detailed instructions can be found on the Free Nights and Weekends Blog.

  1. Install SQLite Firefox extension. This extension provides an easy, GUI-based, editor to create and manage your SQLite database.
  2. Create a new database.
  3. Add a table
  4. Save the file in the Resource folder in your project.
  5. In your project, right click on the Resource folder and click Add > Existing Files…
  6. Choose your saved database. Make sure Relative to Enclosing Group is selected under the Path Type

 

Script
Now we are ready to edit our database.

//Add ready listener
lg.bind('lg_init', init);

function init() {
   //Open database
   lg.database.open({type:'file', name:'database'});

   //Insert new row
   lg.database.execute('INSERT INTO Test ("itemName") VALUES ("added2")');

   //Add listener
   lg.bind('lg_database', gotResults);

   //Select rows
   lg.database.query('SELECT * FROM Test');
}

//Once the results are retrieved, the following listener is called.
function gotResults() {
   //Remove listener
   lg.unbind('lg_database', gotResults);

   //Get results
   console.log(lg.database.results[0].itemName);
}