.. | ||
README.md | ||
shell.c | ||
sqlite3.c | ||
sqlite3.h | ||
sqlite3ext.h |
Custom configuration
If you want to use a customized version of SQLite3 with better-sqlite3
, you can do so by specifying the directory of your custom amalgamation during installation.
npm install better-sqlite3 --build-from-source --sqlite3=/path/to/sqlite-amalgamation
However, if you simply run npm install
while better-sqlite3
is listed as a dependency in your package.json
, the required flags above will not be applied. Therefore, it's recommended that you remove better-sqlite3
from your dependency list, and instead add a preinstall
script like the one shown below.
{
"scripts": {
"preinstall": "npm install better-sqlite3@'^7.0.0' --no-save --build-from-source --sqlite3=\"$(pwd)/sqlite-amalgamation\""
}
}
Your amalgamation directory must contain sqlite3.c
and sqlite3.h
. Any desired compile time options must be defined directly within sqlite3.c
.
Step by step example
If you're creating a package that relies on a custom build of better-sqlite3
, you can follow these steps to get started.
- Download the SQLite3 source code from their website (e.g.,
sqlite-amalgamation-1234567.zip
) - Unzip the compressed archive
- Move the
sqlite3.c
andsqlite3.h
files to your project folder - Add a
preinstall
script to yourpackage.json
, like the one shown above - Make sure the
--sqlite3
flag points to the location of yoursqlite3.c
andsqlite3.h
files - Define your preferred compile time options at the top of
sqlite3.c
- Run
npm install
in your project folder
If you're using a SQLite3 encryption extension that is a drop-in replacement for SQLite3 (such as SEE or sqleet), then simply replace sqlite3.c
and sqlite3.h
with the source files of your encryption extension.
Bundled configuration
By default, this distribution currently uses SQLite3 version 3.35.2 with the following compilation options:
SQLITE_DQS=0
SQLITE_LIKE_DOESNT_MATCH_BLOBS
SQLITE_THREADSAFE=2
SQLITE_USE_URI=0
SQLITE_DEFAULT_MEMSTATUS=0
SQLITE_OMIT_DEPRECATED
SQLITE_OMIT_GET_TABLE
SQLITE_OMIT_TCL_VARIABLE
SQLITE_OMIT_PROGRESS_CALLBACK
SQLITE_OMIT_SHARED_CACHE
SQLITE_TRACE_SIZE_LIMIT=32
SQLITE_DEFAULT_CACHE_SIZE=-16000
SQLITE_DEFAULT_FOREIGN_KEYS=1
SQLITE_DEFAULT_WAL_SYNCHRONOUS=1
SQLITE_ENABLE_COLUMN_METADATA
SQLITE_ENABLE_UPDATE_DELETE_LIMIT
SQLITE_ENABLE_STAT4
SQLITE_ENABLE_FTS3_PARENTHESIS
SQLITE_ENABLE_FTS3
SQLITE_ENABLE_FTS4
SQLITE_ENABLE_FTS5
SQLITE_ENABLE_JSON1
SQLITE_ENABLE_RTREE
SQLITE_ENABLE_GEOPOLY
SQLITE_INTROSPECTION_PRAGMAS
SQLITE_SOUNDEX