How to use the sqlite.Database function in sqlite

To help you get started, we’ve selected a few sqlite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LockerProject / Locker / Connectors / Twitter / dataStore.js View on Github external
*
* Copyright (C) 2011, The Locker Project
* All rights reserved.
*
* Please see the LICENSE file for more information.
*
*/

var IJOD = require('../../Common/node/ijod').IJOD;
var sqlite = require('sqlite');

// var INDEXED_FIELDS = [{fieldName:'timeStamp', fieldType:'REAL'}, {fieldName:'data.id', fieldType:'REAL'}];

var people = {};
var statuses = {};
var currentDB = new sqlite.Database();
exports.init = function(callback) {
    if(!people.followers && ! people.friends) {
        people.followers = new IJOD('followers');
        people.friends = new IJOD('friends');
        statuses.home_timeline = new IJOD('home_timeline');
        statuses.user_timeline = new IJOD('user_timeline');
        statuses.mentions = new IJOD('mentions');
        people.followers.init(function() {
            people.friends.init(function() {
                statuses.home_timeline.init(function() {
                    statuses.user_timeline.init(function() {
                        statuses.mentions.init(function() {
                            openDB(callback);
                        });
                    });
                });
github LockerProject / Locker / Connectors / FirefoxURLS / extract.js View on Github external
/*
*
* Copyright (C) 2011, The Locker Project
* All rights reserved.
*
* Please see the LICENSE file for more information.
*
*/

var sys    = require('sys'),
    sqlite = require('sqlite');

var db = new sqlite.Database();

// open the database for reading if file exists
// create new database file if not

var fs = require('fs');
var exec  = require('child_process').exec;

fs.mkdir('my', 0755);

function copyAndExtract(accountID) {
    child = exec('cp ' + process.env.HOME + '/Library/Application\\ Support/Firefox/Profiles/7v61pmci.default/places.sqlite places.sqlite', function(error, stdout, stderr) {
        fs.mkdir('my/' + accountID, 0755);
        var stream = fs.createWriteStream('my/' +accountID + '/history.json');
        db.open('places.sqlite', function (error) {
          if (error) {
              console.log("Tonight. You.");
github 4poc / feedability / lib / cookie.js View on Github external
var load = function() {
  var config = cfg.get('cookies');

  if(cookie_jar !== null || !config.activate) {
    log.info('cookie storage load skiped')
    return; // return if already loaded
  }

  log.info('loading cookie storage');

  if(config['type'] == 'firefox_sqlite') {
    var db = new sqlite.Database();
    db.open(config['cookie_jar'], function(error) {
      if(error) {
        log.error('unable to load cookie_sqlite: ' + config['cookie_jar']);
        return;
      }

      var sql = 'SELECT * FROM moz_cookies';
      db.execute(sql, function(error, rows) {
        if(error) {
          log.error('error execute sqlite query: '+error);
          return;
        }

        cookie_jar = [];
        for(var i = 0; i < rows.length; i++) {
          // whitelist configuration, if set (not empty), match with host field 
github LockerProject / Locker / Connectors / FirefoxHistory / client.js View on Github external
* Copyright (C) 2011, The Locker Project
* All rights reserved.
*
* Please see the LICENSE file for more information.
*
*/

var fs      = require('fs'),
    sqlite  = require('sqlite'),
    express = require('express'),
    connect = require('connect'),
    spawn   = require('child_process').spawn,
    lfs     = require('../../Common/node/lfs.js'),
    locker  = require('../../Common/node/locker.js');

var db = new sqlite.Database();
var app = express.createServer(
    connect.bodyParser(),
    connect.cookieParser(),
    connect.session({secret: "locker"})
);

app.get('/', function(req, res) {
    res.end("we'll be chugging away...");
    
    // TODO: Check for existing JSON dump and update if exists
    fs.mkdir('my', 0755);

    var ff_profiles_dir = null;
    switch (process.platform) {
    // TODO: Add paths for other platforms
    case "darwin":
github LockerProject / Locker / Connectors / SimpleJournal / simplejournal.js View on Github external
function prepareDb()
{
    db = new sqlite.Database();
    db.open("journal.sqlite", function(error) {
        if (error) {
            process.stderr.write("DB Startup error:" + error + "\n");
            process.exit(1);
        }
        db.execute("SELECT name FROM sqlite_master WHERE name='journal'", function(error, results) {
            if (error)  {
                process.stderr.write("Finding journal error: " + error + "\n");
                db.close();
                process.exit(1);
            }

            if (results.length == 0) {
                db.execute("CREATE TABLE journal(timestamp INT PRMIARY KEY, event TEXT)", function(error, results) {
                    if (error) {
                        process.stderr.write("Journal create table error: " + error + "\n");
github LockerProject / Locker / Connectors / ChromeHistory / client.js View on Github external
res.download(crxName, 'locker-browser-history.crx', function() {
            fs.unlink(crxName);
        });
    });
});

app.get('/allLinks', function(req, res) {
    getURLs(function(error, rows) {
        if(error) throw error;
        res.end(JSON.stringify(rows));
    });
})
var port;
var stdin = process.openStdin();

var db = new sqlite.Database();


stdin.setEncoding('utf8');
stdin.on('data', function (chunk) {
    var processInfo = JSON.parse(chunk);
    process.chdir(processInfo.workingDirectory);
    db.open("history.db", function (error) {
        createTable(function () {
            externalBase = processInfo.externalBase;
            port = processInfo.port;
            var returnedInfo = {port: processInfo.port};
            app.listen(processInfo.port);
            console.log(JSON.stringify(returnedInfo));
        });
    });
});
github LockerProject / Locker / Connectors / foursquare / dataStore.js View on Github external
/*
*
* Copyright (C) 2011, The Locker Project
* All rights reserved.
*
* Please see the LICENSE file for more information.
*
*/

var IJOD = require('../../Common/node/ijod').IJOD;
var sqlite = require('sqlite');

var INDEXED_FIELDS = [{fieldName:'timeStamp', fieldType:'REAL'}, {fieldName:'data.id', fieldType:'REAL'}];

var friends = undefined;
var currentDB = new sqlite.Database();
exports.init = function(callback) {
    if(!friends) {
        friends = new IJOD('friends', INDEXED_FIELDS);
        places = new IJOD('places', INDEXED_FIELDS);
        friends.init(function() {
            places.init(function() {
                openDB(callback);
            })
        });
    } else {
        callback();
    }
}

function openDB(callback) {
    currentDB.open('current.db', function(err) {
github tnantoka / connect-sqlite / lib / connect-sqlite.js View on Github external
function SQLiteStore(options) {
    options = options || {};
    Store.call(this, options);

    this.table = options.db || 'sessions';
    this.db = new sqlite.Database();
    this.client = new events.EventEmitter();
    var self = this;

    var dbFile = (options.dir || '.') + '/' + this.table + '.db';

    this.db.open(dbFile, function(err) {
      if (err) throw err;
      self.db.executeScript('CREATE TABLE IF NOT EXISTS ' + self.table + ' (' +
        'sid PRIMARY KEY, ' +
        'expired, sess);',
        function(err) {
          if (err) throw err;
          self.client.emit('connect');
        }
      );
    });
github LockerProject / Locker / Common / node / ijod.js View on Github external
function IJOD(name, indexedFields) {
    this.name = name;
    this.indexFile = name + '/' + name + '.index';
    this.dataFile = name + '/' + name + '.json';
    this.dbFile = name + '/' + name + '.db';
    this.indexListFile = name + '/' + name + '.json';
    this.indexedFields = indexedFields;
    this.db = new sqlite.Database();
}
github DracoBlue / spludo / core / database / SqliteDatabaseDriver.js View on Github external
this.connectToDatabase = function(callback) {
        if (that.client === null) {
            var database = require('sqlite').Database();
            database.open(options.database, function(error) {
                that.client = database;
                callback();
            });
        } else {
            callback();
        }
    };

sqlite

SQLite client for Node.js applications with SQL-based migrations API written in Typescript

MIT
Latest version published 6 months ago

Package Health Score

79 / 100
Full package analysis