mardi 11 août 2015

Read multiple cols in sqlite database using sqlite.jsm module

Hi I need to read the whole table as (Select * from "database"), and return the value or if not possible read multiple cols from a database

let dbPromise = Task.spawn(function* () {
    let allValues = [];
    let olddb = yield Sqlite.openConnection({ path:
                                          permissionFilePath});

    try {
        let oldMozHosts = olddb.execute("SELECT * FROM 'moz_hosts'");
        allValues = oldMozHosts;
        //console.log("all values: " +allValues);
    }
    finally {
        yield olddb.close();
    }
    
    //return the database
    return allValues;
});

dbPromise.then(function(oldMozHosts) {
    console.log(oldMozHosts);
    var rows = oldMozHosts.execute("SELECT id from 'moz_hosts'");
    ids = row.map(row => row.getResultByIndex(0));
    console.log("ids= "+ids);
}, function(e) {
    console.log("exception:"+ e);
});

Any help will be appreciated, thank you

Aucun commentaire:

Enregistrer un commentaire