# @sqlite3-libs/promised-sqlite3

> A wrapper arround sqlite3 node.js package to use promise

Latest version **1.3.4** (published 2022-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @sqlite3-libs/promised-sqlite3
pnpm add @sqlite3-libs/promised-sqlite3
yarn add @sqlite3-libs/promised-sqlite3
bun add @sqlite3-libs/promised-sqlite3
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.4 |
| Published | 2022-08-08 |
| First published | 2022-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 32.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Tristan Guichaoua |
| Maintainers | mailoman |
| Keywords | sqlite3, promise, async |

## Links

- npm: https://www.npmjs.com/package/@sqlite3-libs/promised-sqlite3
- Repository: https://github.com/sqlite3-libs/promised-sqlite3
- Homepage: https://github.com/sqlite3-libs/promised-sqlite3#readme
- Issues: https://github.com/sqlite3-libs/promised-sqlite3/issues
- npm.io page: https://npm.io/package/@sqlite3-libs/promised-sqlite3

## Dependencies (2)

- [sqlite3](https://npm.io/package/sqlite3.md) ^5.0.8
- [@types/sqlite3](https://npm.io/package/@types/sqlite3.md) ^3.1.6

## Alternatives

- [promise-throttle](https://npm.io/package/promise-throttle.md) — 44.2K weekly downloads
- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads

## Recent versions

- 1.3.4 (latest) — 2022-08-08
- 1.3.3 — 2022-08-08
- 1.3.2 — 2022-08-08
- 1.3.1 — 2022-08-08

## README

# promised-sqlite3
A wrapper for sqlite3 node.js package to use Promise.

[![NPM version](https://badge.fury.io/js/@sqlite3-libs%2Fpromised-sqlite3.svg)](https://www.npmjs.com/package/@sqlite3-libs/promised-sqlite3)

## Motivation
<a href="https://www.npmjs.com/package/sqlite3">sqlite3</a> is a callback-based SQLite3 binding for Node.js.  
<a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a> is a cool javascript feature.

The goal of promised-sqlite3 is to provide a wrapper arround sqlite3 to provide Promise-friendly methods.

## Install
```
npm install @sqlite3-libs/promised-sqlite3
```

## Usage
```javascript
const { PromisedDatabase } = require("@sqlite3-libs/promised-sqlite3"); // import the class

const db = new PromisedDatabase(); // create a instance of PromisedDatabase
// note: at this stade, the wrapped sqlite3.Database object is not created.

async function init() {
    try {
        await db.open("./db.sqlite"); // create a sqlite3.Database object & open the database on the passed filepath.

        // run some sql request.
        await db.run("CREATE TABLE IF NOT EXISTS foo (id INTEGER PRIMARY KEY AUTOINCREMENT, a TEXT NOT NULL, b TEXT)"); 
        await db.run("INSERT INTO foo (a, b) VALUES (?, ?)", "alpha", "beta");
        await db.run("INSERT INTO foo (a, b) VALUES ($goo, $hoo)", { $goo: "GOO !", $hoo: "HOO :" });
        await db.run("INSERT INTO foo (a, b) VALUES (?, ?)", ["Value of a", "Value of b"]);

        // read database
        const row = await db.get("SELECT * FROM foo WHERE id = ?", 2);
        console.log(row2);

        const rows = await db.all("SELECT * FROM foo");
        console.log(rows);

        await db.each("SELECT * FROM foo WHERE id > ?", 5,
            function(row) {
                console.log(row);
            }
        );

        // get the wrapped sqlite3.Database object
        const sqliteDB = db.db;

        // close the database
        await db.close();

    } catch(err) {
        console.error(err);
    }
}

init();
```
## Documentation
See in `./docs/` folder.

---
_Source: https://npm.io/package/@sqlite3-libs/promised-sqlite3 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
