Herdr UI
Herdr의 TUI가 뛰어나며, 창을 통해 추가되는 기능
브라우저 저장소 확장을 지원하는 WebAssembly SQLite
WebAssembly SQLite with support for browser storage extensions
개발 도구JavaScript · CGitHub @rhashimoto직접 설치운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
메이커가 쓴 소개는 위의 한 줄이 전부입니다. 더 자세한 내용은 저장소 README에서 읽을 수 있습니다. 저장소 README ↗
README 전체를 불러오는 중입니다.
README 전문 보기 ↗This is a WebAssembly build of SQLite with support for writing SQLite virtual filesystems completely in Javascript. This allows alternative browser storage options such as IndexedDB and Origin Private File System. Applications can opt to use either a synchronous or asynchronous (using Asyncify or JSPI) SQLite library build (an asynchronous build is required for asynchronous extensions).
IndexedDB and several Origin Private File System virtual file systems are among the examples provided as proof of concept. A table comparing the different VFS classes is here.
Try the demo or run benchmarks with a modern desktop web browser. More information is available in the FAQ, discussion forums, and API reference.
The primary motivation for this project is to enable additions to SQLite with only Javascript. Most developers should be able to use the pre-built artifacts in ./dist. Note that earlier versions of the project only provided pre-built artifacts in the "buildless" branch; that branch will no longer be maintained.
Minor build customization (e.g. changing build defines or flags) can be done with make arguments, and the helper project sqwab can be used to build without a local build environment.
If you do want to build yourself, here are the prerequisites:
yarn - If you use a different package manager (e.g. npm) then file paths in the demo will need adjustment.curl, make, openssl, sed, tclsh, unzipHere are the build steps:
emcc works.git clone [email protected]:rhashimoto/wa-sqlite.gitcd wa-sqliteyarn installmakeThe default build produces ES6 modules + WASM, synchronous and asynchronous (using Asyncify and JSPI) in dist/.
Javascript wrappers for core SQLITE C API functions (and some others) are provided. Some convenience functions are also provided to reduce boilerplate. Here is sample code to load the library and call the API:
import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';
import * as SQLite from 'wa-sqlite';
async function hello() {
const module = await SQLiteESMFactory();
const sqlite3 = SQLite.Factory(module);
const db = await sqlite3.open_v2('myDB');
await sqlite3.exec(db, `SELECT 'Hello, world!'`, (row, columns) => {
console.log(row);
});
await sqlite3.close(db);
}
hello();
There is a slightly more complicated example here that also shows how to use a virtual filesystem (VFS) for persistent storage.
The implementation of sqlite3.exec may be of interest to anyone wanting more fine-grained use of SQLite statement objects (e.g. for binding parameters, explicit column datatypes, etc.).
To serve the demo directly from the source tree:
yarn startThe demo page provides access to databases on multiple VFS implementations. Query parameters on the demo page URL can be used to specify the configuration and initial state:
| Parameter | Purpose | Values | Default |
|---|---|---|---|
| build | Emscripten build type | default, asyncify, jspi | default |
| config | select VFS | MemoryVFS, MemoryAsyncVFS, IDBBatchAtomicVFS, IDBMirrorVFS, AccessHandlePoolVFS, OPFSAdaptiveVFS, OPFSAnyContextVFS, OPFSCoopSyncVFS, OPFSWriteAheadVFS | uses SQLite internal memory |
| reset | clear persistent storage |
For convenience, if any text region is selected in the editor, only that region will be executed. In addition, the editor contents are restored across page reloads using browser localStorage.
MIT License as of February 10, 2023, changed by generous sponsors Fleet Device Management and Reflect. Existing licensees may continue under the GPLv3 or switch to the new license.