Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What SQLite to use with nodejs

Tags:

node.js

sqlite

I am developing application using node.js. In that I am willing to use SQLite as embedded database. I searched online for SQLite npm modules. I found various modules:

  1. https://github.com/grumdrig/node-sqlite
  2. https://github.com/orlandov/node-sqlite
  3. https://github.com/developmentseed/node-sqlite3

From documentation and other sources, I understood that (1) operates synchronously, while (2) and (3) works asynchronously. So, I dropped the plan to use (1).

Now, I want to know what is the difference between (2) and (3) and which one should be preferred? I googled a lot but could not find much to help.

like image 643
jsist Avatar asked Jan 16 '13 09:01

jsist


People also ask

Can I use SQLite with node js?

Node. js can be used very well with relational databases and SQLite is no exception.

What DB to use with Nodejs?

Node. js supports all kinds of databases no matter if it is a relational database or NoSQL database. However, NoSQL databases like MongoDb are the best fit with Node.


2 Answers

Use https://github.com/mapbox/node-sqlite3. It's asynchronous (almost a must-have), it's the most actively maintained, and it has the most stars on GitHub.

like image 126
Trevor Dixon Avatar answered Oct 21 '22 04:10

Trevor Dixon


Alternatively, you could use a javascript embedded database. This way you just need to declare the database as a dependency in your package.json and require() it in your application.

Check out NeDB (which I wrote) or nStore for example.

like image 25
Louis Chatriot Avatar answered Oct 21 '22 03:10

Louis Chatriot