Trying to access Places.SQLite with Storage/Services/FileUtils

by SSRRDD

JavaScript

Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");

let file = FileUtils.getFile("ProfD", ["places.sqlite"]);
let dbConn = Services.storage.openDatabase(file); // Will also create the file if it does not exist

var statement = dbConn.createStatement("SELECT name FROM moz_anno_attributes");

statement.executeAsync({
  handleResult: function(aResultSet)
  {
    for (let row = aResultSet.getNextRow();
         row;
         row = aResultSet.getNextRow())
    {
    	let value = row.getResultByName("name");
	  	console.log("TEST", value);
    }
  },

  handleError: function(aError)
  {
    print("Error: " + aError.message);
  },

  handleCompletion: function(aReason)
  {
    if (aReason != Components.interfaces.mozIStorageStatementCallback.REASON_FINISHED)
      print("Query canceled or aborted!");
  }
});

dbConn.close()