How to use the sqlite3.OPEN_READONLY function in sqlite3

To help you get started, we’ve selected a few sqlite3 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 tsycnh / WeChatExporter / development / js / controller / chatDetail.js View on Github external
$scope.outputPath.rootFolder = $stateParams.outputPath;
        $scope.outputPath.sqliteFile = path.join($scope.outputPath.rootFolder,"data.sqlite");
        $scope.outputPath.audioFolder = path.join($scope.outputPath.rootFolder,"audio");
        $scope.outputPath.imageFolder = path.join($scope.outputPath.rootFolder,"image");
        $scope.outputPath.imageThumbnailFolder = path.join($scope.outputPath.rootFolder,"image","thumbnail");
        $scope.outputPath.videoFolder = path.join($scope.outputPath.rootFolder,"video");
        $scope.outputPath.videoThumbnailFolder = path.join($scope.outputPath.rootFolder,"video","thumbnail");
        $scope.outputPath.resourceFolder = path.join($scope.outputPath.rootFolder,"resource");

        $scope.meInfo['headPath'] = path.join('file://',$scope.outputPath.resourceFolder,'me.png')
        $scope.otherInfo['headPath'] = path.join('file://',$scope.outputPath.resourceFolder,'other.png')

        console.log($scope.outputPath);

        //- 打开sqlite数据库
        $scope.db = new sqlite3.Database($scope.outputPath.sqliteFile,sqlite3.OPEN_READONLY,function (error) {
            if (error){console.log("Database error:",error);}
        });
        //- 计算一共有多少页
        var sqlite = require('sqlite-sync'); //requiring
        sqlite.connect($scope.outputPath.sqliteFile);
        $scope.totalMessageCount = sqlite.run("SELECT count(*) as count from ChatData")[0].count;
        $scope.totalPageCount = Math.ceil($scope.totalMessageCount/$scope.limitGap);

        $scope.currentPage = 1;
        //- 按照limit规则,每按一次loadMore载入指定数量的消息
        //$scope.loadMore();// 载入数据库内容
        if($scope.generateHtml == "true")
        {
            fse.emptyDirSync("../distHtml");
        }
        $scope.goToPage($scope.currentPage);
github taichi / rx-sqlite / src / index.js View on Github external
// @flow
import * as sqlite from "sqlite3";
import db from "./database";
import stmt from "./statement";

/**
 * see {@link https://github.com/mapbox/node-sqlite3/wiki/Debugging|node-sqlite3/Debugging}
 */
export function verbose() {
  sqlite.verbose();
}

/**
 * The database is opened in read-only mode.
 */
export const OPEN_READONLY = sqlite.OPEN_READONLY;

/**
 * The database is opened for reading and writing if possible.
 */
export const OPEN_READWRITE = sqlite.OPEN_READWRITE;

/**
 * The database is opened for reading and writing, and is created if it does not already exist.
 */
export const OPEN_CREATE = sqlite.OPEN_CREATE;

/**
 * supported database opening flags
 */
export type Mode = OPEN_READONLY | OPEN_READWRITE | OPEN_CREATE;
github tramseyer / cell-geolocation / uwl_cells-cleanup.js View on Github external
const sqlite3 = require('sqlite3');
const path = require('path');
const util = require('util');
const request = require(path.join(__dirname,'./request.js'));
const mlsDb = new sqlite3.Database(path.join(__dirname, 'mls_cells.sqlite'), sqlite3.OPEN_READONLY);
const ociDb = new sqlite3.Database(path.join(__dirname, 'oci_cells.sqlite'), sqlite3.OPEN_READONLY);
const glmDb = new sqlite3.Database(path.join(__dirname, 'glm_cells.sqlite'), sqlite3.OPEN_READONLY);
const uwlDb = new sqlite3.Database(path.join(__dirname, 'uwl_cells.sqlite'), sqlite3.OPEN_READWRITE);

var numProcessedEntries = 0;

uwlDb.each("SELECT mcc, mnc, lac, cellid FROM cells", function(err, uwlRow) {
  if (err) {
    console.error('Error querying OpenCellId cache database');
    return;
  } else {
    numProcessedEntries++;
    mlsDb.get('SELECT lat, lon, range FROM cells WHERE mcc = ? AND mnc = ? AND lac = ? AND cellid = ?', {
      1: uwlRow.mcc,
      2: uwlRow.mnc,
      3: uwlRow.lac,
github inukshuk / sqleton / bin / sqleton.js View on Github external
alias: 'out', required: true, describe:
      'Output file (determines output format)'
  })

  .argv



function fail(error) {
  if (error) {
    process.stderr.write(`${error.stack}\n`)
  }
  process.exit(1)
}

const db = new sqlite.Database(argv._[0], sqlite.OPEN_READONLY, error => {
  if (error) return fail(error)

  let format = extname(argv.out).slice(1)
  let stream, proc

  if (format !== 'dot') {
    proc = spawn(argv.layout, [`-T${format}`, `-o${argv.out}`])
    proc.stderr.pipe(process.stderr)

    stream = proc.stdin

  } else {
    stream = open(argv.out, { autoClose: true })
  }

  sqleton(db, stream, argv)
github jiacai2050 / history-master / lib / db.js View on Github external
exports.initDB = function(firefoxHistoryFile, chromeHistoryFile) {
    var config_dir = util.getConfDir();
    chromeHistoryFile = findChromeHistoryFile(chromeHistoryFile);
    firefoxHistoryFile = findFirefoxHistoryFile(firefoxHistoryFile);
    if (chromeHistoryFile) {
        var localHistoryFile = path.join(config_dir, path.basename(chromeHistoryFile));
        fs.copySync(chromeHistoryFile, localHistoryFile);
        chromeDB = new sqlite3.Database(localHistoryFile, sqlite3.OPEN_READONLY);
        console.log("Load Chrome history successfully....".green);
    }
    if (firefoxHistoryFile) {
        var localHistoryFile = path.join(config_dir, path.basename(firefoxHistoryFile));
        fs.copySync(firefoxHistoryFile, localHistoryFile);
        firefoxDB = new sqlite3.Database(localHistoryFile, sqlite3.OPEN_READONLY);
        console.log("Load Firefox history successfully....".green);
    }
}
github irr / R-trader / js / server.js View on Github external
function load(req, res, symbol, file, range) {
    var sqlite3 = require('sqlite3');
    var db = new sqlite3.Database(file, sqlite3.OPEN_READONLY, doload);

    function edb(e, f) {
        if (!e) {
            f();
        } else {
            emitter.emit("db-load-error", req, res, symbol, e);
            db.close();
        }
    }

    function doload(e) {
        edb(e, function() {
            var args = sql(symbol, range);
            db.all(args.query, args.bindings, dofetch);
        });
    }
github node-red / node-red-nodes / storage / sqlite / sqlite.js View on Github external
function SqliteNodeDB(n) {
        RED.nodes.createNode(this,n);

        this.dbname = n.db;
        this.mod = n.mode;
        if (n.mode === "RWC") { this.mode = sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE; }
        if (n.mode === "RW") { this.mode = sqlite3.OPEN_READWRITE; }
        if (n.mode === "RO") { this.mode = sqlite3.OPEN_READONLY; }
        var node = this;

        node.doConnect = function() {
            node.db = node.db || new sqlite3.Database(node.dbname,node.mode);
            node.db.on('open', function() {
                if (node.tick) { clearTimeout(node.tick); }
                node.log("opened "+node.dbname+" ok");
            });
            node.db.on('error', function(err) {
                node.error("failed to open "+node.dbname, err);
                node.tick = setTimeout(function() { node.doConnect(); }, reconnect);
            });
        }

        node.on('close', function (done) {
            if (node.tick) { clearTimeout(node.tick); }
github toyobayashi / mishiro / app / src / ts / main / sqlite3.ts View on Github external
export function openSqlite (db: string, mode = sqlite3.OPEN_READONLY): Promise {
  return new Promise((resolve, reject) => {
    let d = new sqlite3.Database(db, mode, (err: Error | null) => {
      if (err) reject(err)
      else resolve(d)
    })
  })
}
github zubairq / pilot / src / exeScheduler.js View on Github external
sendToProcess(  id,
                                            parentCallId,
                                            callbackIndex,
                                            processName,
                                            results[0].base_component_id,
                                            results[0].on_condition,
                                            args)



                        }
                    }
                })
    }, sqlite3.OPEN_READONLY)

    }
github mozilla / promise-sqlite / src / index.js View on Github external
* @module SQLite
 */

import sqlite3 from 'sqlite3';
import thenifyAll from 'thenify-all';

const Promise = global.Promise;
const debug = false;

export function verbose() {
  sqlite3.verbose();
}

export const OPEN_CREATE = sqlite3.OPEN_CREATE;
export const OPEN_READWRITE = sqlite3.OPEN_READWRITE;
export const OPEN_READONLY = sqlite3.OPEN_READONLY;

/**
 * Turn methods on `source` that return callbacks into methods on `dest` that are bound to
 * `source` as if invoked as method calls.
 *
 * @param source an object with methods named by `methods`.
 * @param dest an object upon which attributes will be set.
 * @param methods an array of method names.
 */
function thenifyMethods(source, dest, methods) {
  const wrapped = thenifyAll(source, {}, methods);
  for (const method of methods) {
    dest[method] = wrapped[method].bind(source);
  }
}

sqlite3

Asynchronous, non-blocking SQLite3 bindings

BSD-3-Clause
Latest version published 12 months ago

Package Health Score

81 / 100
Full package analysis