Socket
Socket
Sign inDemoInstall

sqlite3-promisify

Package Overview
Dependencies
71
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sqlite3-promisify

Promisify all node-sqlite3 functions


Version published
Weekly downloads
4
increased by33.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

sqlite3-promisify

Build Status

Promisifying node-sqlite3 functions

Install

npm i sqlite3-promisify

Usage

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

Read our contributing guide 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:

Keywords

FAQs

Last updated on 04 Aug 2021

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