npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

sqlite3-ext

v1.0.0

Published

Asynchronous, non-blocking SQLite3 bindings with user functions support

Downloads

4

Readme

Asynchronous, non-blocking SQLite3 bindings for Node.js.

Extended version

Supported platforms

The sqlite3 module works with Node.js v4.x, v6.x, v8.x, and v10.x.

The sqlite3 module also works with node-webkit if node-webkit contains a supported version of Node.js engine. (See below.)

SQLite's SQLCipher extension is also supported. (See below.)

Usage

Note: the module must be installed before use.

var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(':memory:');

db.serialize(function() {
  db.run("CREATE TABLE lorem (info TEXT)");

  var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
  for (var i = 0; i < 10; i++) {
      stmt.run("Ipsum " + i);
  }
  stmt.finalize();

  db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
      console.log(row.id + ": " + row.info);
  });
});

db.close();

Custom functions

First implementation by Whitney Young

    var sqlite3 = require('sqlite3').verbose();
    var db = new sqlite3.Database(':memory:', function() {
          db.registerFunction('A_PLUS_B', function(a, b) {
              return a+b;
          });
          
          db.all('SELECT A_PLUS_B(1, 2) AS val', function(err, rows) {
              console.log(row.id + ": " + row.info); //Prints [{val: 3}]
          });
          
          db.close();
    });
    

Custom aggregate

    var sqlite3 = require('sqlite3').verbose();
    var db = new sqlite3.Database(':memory:', function() {
          let tempStr = '';
          db.registerAggregateFunction('CUSTOM_AGGREGATE', function(value) {
              if(!value){
                  return tempStr;
              }
              tempStr+= value;
          });
          
          db.all('SELECT CUSTOM_AGGREGATE(id) AS val', function(err, rows) {
              console.log(row.id + ": " + row.info); //Prints [{val: '123456'}] if table has 6 rows with id field
          });
          
          db.close();
    });
    

Features

  • Straightforward query and parameter binding interface
  • Full Buffer/Blob support
  • Extensive debugging support
  • Query serialization API
  • Extension support
  • Big test suite
  • Written in modern C++ and tested for memory leaks
  • Bundles Sqlite3 3.15.0 as a fallback if the installing system doesn't include SQLite
  • Custom functions. Implemented sqlite_create_function

API

See the API documentation in the wiki.

Installing

You can use npm to download and install:

  • GitHub's master branch: npm install https://github.com/lailune/node-sqlite3/tarball/master

It is possible to use the installed package in node-webkit instead of the vanilla Node.js.

Testing

mocha is required to run unit tests.

In sqlite3's directory (where its package.json resides) run the following:

npm install mocha
npm test

Contributors

Acknowledgments

Originally developed by MapBox