Socket
Socket
Sign inDemoInstall

sqlite3-sync

Package Overview
Dependencies
91
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sqlite3-sync

synchronous sqlite bindings


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

sqlite3-sync

Synchronous Napi-bindings for libsqlite.

While the sqlite3-package for node.js is fine and usefull for server applications, its use tends to become overly complicated for simple scripting tasks..

So I immplemented a simple Napi based wrapper for libsqlite. Unlike other implementations, this package does not use libffi, mainly because i got into trouble using libffi on my target plattform. And just wrapping libsqlite myself seemed to be easier than tweaking or fixing foreign code.

Usage

Install the package via npm:

npm install sqlite3-sync

and use it:

let Sqlite = require('sqlite3-sync');
let db = Sqlte('my-db.sqlite');

db.each("SELECT name FROM customer", 
    (row) => { console.log(row.customer); },
    () => { console.log("eof); }
);

Api

let database = Sqlite(dbname, mode)

creates a database connection.

database.close()

close the database

row = database.get(sql_statment, arg_array)

prepares a statement, binds an array of arguments and returns the first resulting row.

list = database.all(sql_statment, arg_array)

prepares a statement, binds an array of arguments and returns the all resulting rows as an array.

database.run(sql_statment, arg_array)

prepares a statement, binds an array of arguments and runs the statement. This is equivalent to get()

database.exec(sql_statment, arg_array)

prepares a statement, binds an array of arguments and runs the statement. This is equivalent to get()

database.each(sql_statment, arg_array, function callback (row) => { }, function finally() => {} )

prepares a statement, binds an array of arguments and and opens a cursor for the query.

the callback is called once for each resulting row, after that the finally callback is called.

statement = database.prepare(sql_statment, opt_arg_array)

create a raw statemwnt object. This might be seldomly used, refer to index.js for further documention.

FAQs

Last updated on 18 Sep 2020

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