Socket
Socket
Sign inDemoInstall

better-sqlite-pool

Package Overview
Dependencies
101
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    better-sqlite-pool

A connection pool for better-sqlite3.


Version published
Weekly downloads
662
increased by1.85%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Better-SQLite-Pool

A connection pool for the module better-sqlite3.

Using this module to open pools and acquire connections, and release the connection once it has done its work.

Example

const Pool = require("better-sqlite-pool");

// Create a new pool:
var pool = new Pool("./example.db");

// use Promise:
pool.acquire().then(db => {
    var res = db.prepare("select * from users where id = 1").get();
    console.log(res);
    db.release();
});

// use async/await:
(async function() {
    var db = await pool.acquire();
    var res = db.prepare("select * from users where id = 2").get();
    console.log(res);
    db.release();
})();


setImmediate(() => {
    console.log(pool);
});

API

new Pool(path: string, options:? object|boolean|number)

Creates a new pool to store database connections.

  • path A SQLite database file path, can be set to :memory to open a memory based database.
  • [options] May contain any of these:
    • readonly Default is false.
    • memory Default is false.
    • fileMustExist Default is false.
    • max Max connections in the pool, default is 5.
    If this argument is set to a boolean, it's equivalent to readonly, if set to a number, it's equivalent to max.

pool.acquire(): Promise<Database>

Acquires a connection from the pool.

The only argument pass to the callback of Promise.then() is the database connection retrieved.

pool.close()

Closes all connections in the pool.

Issues

node-gyp error

If you have any problem of downloading and installing this module, it's most likely that you don't have a node-gyp installed in you project first, which is used to compile better-sqlite3 binary files. This module will try to install node-gyp for you, but it may be after installing better-sqlite3, thus causing your trouble. So manually install node-gyp first if this situation suits you.

VCBulid.exe error

Another problem you may face is your computer throw an error that tells you the VCBulid.exe file is missing. This is probably you don't have a Visual Studio installed, install one with VC++ support, that will fix the problem.

FAQs

Last updated on 20 Nov 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc