WiseLibs/better-sqlite3
WiseLibs/better-sqlite3 has 7,548 GitHub stars and 484 forks. GitHot measured +3 stars in 24 hours and +4 in 7 days. Last checked 2026-11-09 04:23 UTC. Last push 2026-08-10.
Node.js용 가장 빠르고 간단한 SQLite3 라이브러리입니다.
What you can do
- 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.
측정된 스타 증가
- in 24h
- +3
- in 7 days
- +4
- in 15 days
- 기록 수집 중
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalbetter-sqlite3 
The fastest and simplest library for SQLite 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
Requires a currently supported Node.js version. Prebuilt binaries are available for major platforms/architectures. 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);
Though not required, it is generally important to set the WAL pragma for performance reasons.
db.pragma('journal_mode = WAL');
In ES6 module notation:
import Database from 'better-sqlite3';
const db = new Database('foobar.db', options);
db.pragma('journal_mode = WAL');
Why should I use this instead of node-sqlite3?
node-sqlite3uses 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-sqlite3exposes low-level (C language) memory management functions.better-sqlite3does it the JavaScript way, allowing the garbage collector to worry about memory management.better-sqlite3is simpler to use, and it provides nice utilities for some operations that are very difficult or impossible innode-sqlite3.better-sqlite3is much faster thannode-sqlite3in 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 SQLite 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 SQLite's serialized nature. Fortunately, SQLite 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.
Upgrading
Upgrading your better-sqlite3 dependency can potentially introduce breaking changes, either in the better-sqlite3 API (if you upgrade to a new major version), or between your existing database(s) and the underlying version of SQLite. Before upgrading, review:
Documentation
- API documentation
- Performance (also see benchmark results)
- 64-bit integer support
- Worker thread support
- Unsafe mode (advanced)
- SQLite compilation (advanced)
- Contribution rules
- Code of conduct
License
관련 프로젝트 살펴보기
Asabeneh/30-Days-Of-Python
30 Days of Python 프로그래밍 챌린지는 Python 프로그래밍 언어를 30일 동안 배우기 위한 단계별 가이드입니다. 이 챌린지는 100일 이상 걸릴 수 있습니다. 자신의 속도에 맞춰 진행하세요. 다음 동영상도 도움이 될 수 있습니다: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,423 스타grafana/grafana
개방적이고 조합 가능한 옵저버빌리티 및 데이터 시각화 플랫폼입니다. Prometheus, Loki, Elasticsearch, InfluxDB, Postgres 등 여러 소스의 메트릭, 로그, 트레이스를 시각화합니다.
77,763 스타redis/redis
실시간 데이터 기반 애플리케이션을 구축하는 개발자에게 Redis는 가장 선호되고, 가장 빠르며, 기능이 가장 풍부한 캐시, 데이터 구조 서버이자 문서 및 벡터 쿼리 엔진입니다.
77,309 스타apache/superset
Apache Superset는 데이터 시각화 및 데이터 탐색 플랫폼입니다.
75,453 스타