All Projects → JoshuaWise → Better Sqlite3

JoshuaWise / Better Sqlite3

Licence: mit
The fastest and simplest library for SQLite3 in Node.js.

Programming Languages

C++
36643 projects - #6 most used programming language
javascript
184084 projects - #8 most used programming language
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Better Sqlite3

Squeal
A Swift wrapper for SQLite databases
Stars: ✭ 303 (-89.09%)
Mutual labels:  sql, database, sqlite, sqlite3
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (-54.39%)
Mutual labels:  sql, database, sqlite, sqlite3
Nut
Advanced, Powerful and easy to use ORM for Qt
Stars: ✭ 181 (-93.48%)
Mutual labels:  sql, database, sqlite
Sqlite3 Encryption
The easiest way to build SQLite3 with encryption support on Windows. Compilation of DLL, SLL or shell is now a matter of minutes
Stars: ✭ 102 (-96.33%)
Mutual labels:  database, sqlite, sqlite3
Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (-93.7%)
Mutual labels:  sql, database, sqlite3
Pydbgen
Random dataframe and database table generator
Stars: ✭ 191 (-93.12%)
Mutual labels:  database, sqlite, sqlite3
Qtl
A friendly and lightweight C++ database library for MySQL, PostgreSQL, SQLite and ODBC.
Stars: ✭ 92 (-96.69%)
Mutual labels:  sql, database, sqlite
Kangaroo
SQL client and admin tool for popular databases
Stars: ✭ 127 (-95.43%)
Mutual labels:  sql, database, sqlite
Sql.js
A javascript library to run SQLite on the web.
Stars: ✭ 9,594 (+245.36%)
Mutual labels:  sql, database, sqlite
Esp32 arduino sqlite3 lib
Sqlite3 Arduino library for ESP32
Stars: ✭ 167 (-93.99%)
Mutual labels:  database, sqlite, sqlite3
Sqlcheck
Automatically identify anti-patterns in SQL queries
Stars: ✭ 2,062 (-25.77%)
Mutual labels:  sql, database, sqlite3
Rom Sql
SQL support for rom-rb
Stars: ✭ 169 (-93.92%)
Mutual labels:  sql, sqlite, sqlite3
Ebean
Ebean ORM
Stars: ✭ 1,172 (-57.81%)
Mutual labels:  sql, database, sqlite
D2sqlite3
A small wrapper around SQLite for the D programming language
Stars: ✭ 67 (-97.59%)
Mutual labels:  database, sqlite, sqlite3
Sqlite orm
❤️ SQLite ORM light header only library for modern C++
Stars: ✭ 1,121 (-59.65%)
Mutual labels:  sql, sqlite, sqlite3
Sqhell.vim
An SQL wrapper for vim
Stars: ✭ 113 (-95.93%)
Mutual labels:  sql, sqlite, sqlite3
Trilogy
TypeScript SQLite layer with support for both native C++ & pure JavaScript drivers.
Stars: ✭ 195 (-92.98%)
Mutual labels:  sql, database, sqlite
Rqlite
The lightweight, distributed relational database built on SQLite
Stars: ✭ 9,147 (+229.27%)
Mutual labels:  sql, database, sqlite
Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (-98.16%)
Mutual labels:  database, sqlite, sqlite3
Goose
A database migration tool. Supports SQL migrations and Go functions.
Stars: ✭ 2,112 (-23.97%)
Mutual labels:  sql, database, sqlite

better-sqlite3 Build Status

The fastest and simplest library for SQLite3 in Node.js.

  • Full transaction support
  • High performance, efficiency, and safety
  • Easy-to-use synchronous API (better concurrency than an asynchronous API... yes, you read that correctly)
  • Support for user-defined functions, aggregates, virtual tables, and extensions
  • 64-bit integers (invisible until you need them)
  • Worker thread support (for large/slow queries)

Help this project stay strong! 💪

better-sqlite3 is used by thousands of developers and engineers on a daily basis. Long nights and weekends were spent keeping this project strong and dependable, with no ask for compensation or funding, until now. If your company uses better-sqlite3, ask your manager to consider supporting the project:

How other libraries compare

select 1 row  get()  select 100 rows   all()   select 100 rows iterate() 1-by-1 insert 1 row run() insert 100 rows in a transaction
better-sqlite3 1x 1x 1x 1x 1x
sqlite and sqlite3 11.7x slower 2.9x slower 24.4x slower 2.8x slower 15.6x slower

You can verify these results by running the benchmark yourself.

Installation

npm install better-sqlite3

You must be using Node.js v10.20.1 or above. Prebuilt binaries are available for LTS versions.

If you have trouble installing, check the troubleshooting guide.

Usage

const db = require('better-sqlite3')('foobar.db', options);

const row = db.prepare('SELECT * FROM users WHERE id = ?').get(userId);
console.log(row.firstName, row.lastName, row.email);

Why should I use this instead of node-sqlite3?

  • node-sqlite3 uses asynchronous APIs for tasks that are either CPU-bound or serialized. That's not only bad design, but it wastes tons of resources. It also causes mutex thrashing which has devastating effects on performance.
  • node-sqlite3 exposes low-level (C language) memory management functions. better-sqlite3 does it the JavaScript way, allowing the garbage collector to worry about memory management.
  • better-sqlite3 is simpler to use, and it provides nice utilities for some operations that are very difficult or impossible in node-sqlite3.
  • better-sqlite3 is much faster than node-sqlite3 in most cases, and just as fast in all other cases.

When is this library not appropriate?

In most cases, if you're attempting something that cannot be reasonably accomplished with better-sqlite3, it probably cannot be reasonably accomplished with SQLite3 in general. For example, if you're executing queries that take one second to complete, and you expect to have many concurrent users executing those queries, no amount of asynchronicity will save you from SQLite3's serialized nature. Fortunately, SQLite3 is very very fast. With proper indexing, we've been able to achieve upward of 2000 queries per second with 5-way-joins in a 60 GB database, where each query was handling 5–50 kilobytes of real data.

If you have a performance problem, the most likely causes are inefficient queries, improper indexing, or a lack of WAL mode—not better-sqlite3 itself. However, there are some cases where better-sqlite3 could be inappropriate:

  • If you expect a high volume of concurrent reads each returning many megabytes of data (i.e., videos)
  • If you expect a high volume of concurrent writes (i.e., a social media site)
  • If your database's size is near the terabyte range

For these situations, you should probably use a full-fledged RDBMS such as PostgreSQL.

Documentation

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].