# sqlite3-promisify

> Promisify all node-sqlite3 functions

Latest version **1.0.3** (published 2021-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install sqlite3-promisify
pnpm add sqlite3-promisify
yarn add sqlite3-promisify
bun add sqlite3-promisify
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-08-04 |
| First published | 2019-07-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Arshad Kazmi |
| Maintainers | arshadkazmi42 |
| Keywords | sqlite3, sqlite, node-sqlite3, promisify, sqlite3 promisify |

## Links

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

## Dependencies (1)

- [sqlite3](https://npm.io/package/sqlite3.md) ^4.0.9

## Recent versions

- 1.0.3 (latest) — 2021-08-04
- 1.0.2 — 2021-05-15
- 1.0.1 — 2020-01-10
- 1.0.0 — 2019-07-30

## README

# sqlite3-promisify

[![Build Status](https://api.travis-ci.com/arshadkazmi42/sqlite3-promisify.svg?branch=master)](https://api.travis-ci.com/arshadkazmi42/sqlite3-promisify)

Promisifying node-sqlite3 functions

## Install

```
npm i sqlite3-promisify
```

## Usage

```javascript
const SQLiteCrud = require('sqlite3-promisify');
const DB_PATH = __dirname + '/sqlite3.db';
const DB_NAME = 'sqlite3_test';

(async () => {
  const Db = new SQLiteCrud(DB_PATH);
  const rows = await Db.all(`SELECT * FROM ${DB_NAME};`);
  console.log(rows);

  ////////// OUTPUT ////////////
  // [ 
  //   { id: 1, name: 'Arshad', email: 'arshadkazmi42@gmail.com' },
  //   { id: 2, name: 'Sqlite3', email: 'sqlite3@db.com' }
  // ]


  const row = await Db.get(`SELECT * FROM ${DB_NAME} WHERE id = ?;`, [1]);
  console.log(row);

  ////////// OUTPUT ////////////
  // { id: 1, name: 'Arshad', email: 'arshadkazmi42@gmail.com' }
  
})();
```

## API

- #### `connect(path)`
  Takes SQLite `DB path` as input and returns sqlite3 object.
  - **Params**
    - path (string) - Database absolute path

- #### `serialize()`
  Serialize consecutive db calls.

- #### `get(query, values={Optional})`
  Executes select queries and returns only first result row. 
  - **Params**
    - query (string) - SQL query
    - values (array) - Values for the query

- #### `all(query, values={Optional})`
  Executes any query and returns all the result rows
  - **Params**
    - query (string) - SQL query
    - values (array) - Values for the query

- #### `run(query, values={Optional})`
  Executes query which does not returns any results
  - **Params**
    - query (string) - SQL query
    - values (array) - Values for the query

- #### `close()`
  Closes the db connection

## Contributing

Interested in contributing to this project?
You can log any issues or suggestion related to this library [here](https://github.com/arshadkazmi42/sqlite3-promisify/issues/new)

Read our contributing [guide](CONTRIBUTING.md) on getting started with contributing to the codebase

## Contributors

Thank you to all the contributors who have helped us in making this project better :raised_hands:

<a href="https://github.com/arshadkazmi42"><img src="https://github.com/arshadkazmi42.png" width="30" /></a>

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