{"id":13624210,"url":"https://github.com/rhashimoto/wa-sqlite","last_synced_at":"2025-04-15T20:33:38.854Z","repository":{"id":38827260,"uuid":"359970576","full_name":"rhashimoto/wa-sqlite","owner":"rhashimoto","description":"WebAssembly SQLite with support for browser storage extensions","archived":false,"fork":false,"pushed_at":"2025-04-10T23:16:41.000Z","size":20801,"stargazers_count":1050,"open_issues_count":5,"forks_count":72,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-04-10T23:18:38.545Z","etag":null,"topics":["indexeddb","javascript","opfs","sqlite","vfs","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rhashimoto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-20T22:49:37.000Z","updated_at":"2025-04-10T15:57:21.000Z","dependencies_parsed_at":"2023-10-29T20:30:52.724Z","dependency_job_id":"aa057fe8-70a2-4683-9074-ebb12d20a285","html_url":"https://github.com/rhashimoto/wa-sqlite","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhashimoto%2Fwa-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhashimoto%2Fwa-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhashimoto%2Fwa-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rhashimoto%2Fwa-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rhashimoto","download_url":"https://codeload.github.com/rhashimoto/wa-sqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249148433,"owners_count":21220529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["indexeddb","javascript","opfs","sqlite","vfs","wasm","webassembly"],"created_at":"2024-08-01T21:01:40.065Z","updated_at":"2025-04-15T20:33:35.592Z","avatar_url":"https://github.com/rhashimoto.png","language":"JavaScript","readme":"[![wa-sqlite CI](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml/badge.svg)](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml)\n\n# wa-sqlite\nThis 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).\n\nIndexedDB 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](https://github.com/rhashimoto/wa-sqlite/tree/master/src/examples#vfs-comparison).\n\n[Try the demo](https://rhashimoto.github.io/wa-sqlite/demo/?build=asyncify\u0026config=IDBBatchAtomicVFS\u0026reset) or run [benchmarks](https://rhashimoto.github.io/wa-sqlite/demo/benchmarks/?config=asyncify,IDBBatchAtomicVFS;asyncify,IDBMirrorVFS;default,AccessHandlePoolVFS;default,OPFSCoopSyncVFS;asyncify,OPFSAdaptiveVFS;asyncify,OPFSPermutedVFS) with a modern desktop web browser. More information is available in the [FAQ](https://github.com/rhashimoto/wa-sqlite/issues?q=is%3Aissue+label%3Afaq+), [discussion forums](https://github.com/rhashimoto/wa-sqlite/discussions), and [API reference](https://rhashimoto.github.io/wa-sqlite/docs/).\n\n## Build\nThe 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\n[./dist](https://github.com/rhashimoto/wa-sqlite/tree/master/dist).\nNote that earlier versions of the project only provided pre-built artifacts in the\n\"buildless\" branch; that branch will no longer be maintained.\n\nMinor build customization (e.g. changing build defines or flags) can be done with [make arguments](https://github.com/rhashimoto/wa-sqlite/discussions/128), and the helper project [sqwab](https://github.com/rhashimoto/sqwab) can be used to build without a local build environment.\n\nIf you do want to build yourself, here are the prerequisites:\n\n* Building on Debian Linux is known to work, compatibility with other platforms is unknown.\n* `yarn` - If you use a different package manager (e.g. `npm`) then file paths in the demo will need adjustment.\n* [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) 3.1.61+.\n* `curl`, `make`, `openssl`, `sed`, `tclsh`, `unzip`\n\nHere are the build steps:\n* Make sure `emcc` works.\n* `git clone git@github.com:rhashimoto/wa-sqlite.git`\n* `cd wa-sqlite`\n* `yarn install`\n* `make`\n\nThe default build produces ES6 modules + WASM, [synchronous and asynchronous](https://github.com/rhashimoto/wa-sqlite/issues/7) (using Asyncify and JSPI) in `dist/`.\n\n## API\nJavascript 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:\n\n```javascript\n  import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';\n  import * as SQLite from 'wa-sqlite';\n\n  async function hello() {\n    const module = await SQLiteESMFactory();\n    const sqlite3 = SQLite.Factory(module);\n    const db = await sqlite3.open_v2('myDB');\n    await sqlite3.exec(db, `SELECT 'Hello, world!'`, (row, columns) =\u003e {\n      console.log(row);\n    });\n    await sqlite3.close(db);\n  }\n\n  hello();\n```\n\nThere is a slightly more complicated example [here](https://github.com/rhashimoto/wa-sqlite/tree/master/demo/hello) that also shows how to use a virtual filesystem (VFS) for persistent storage.\n\nThe [implementation of `sqlite3.exec`](https://github.com/rhashimoto/wa-sqlite/blob/eb6e62584b2864d5029f51c6afe155d71ba0caa8/src/sqlite-api.js#L409-L418) may be of interest to anyone wanting more fine-grained use of SQLite statement objects (e.g. for binding parameters, explicit column datatypes, etc.).\n\n[API reference](https://rhashimoto.github.io/wa-sqlite/docs/)\n\n## Demo\nTo serve the demo directly from the source tree:\n* `yarn start`\n* Open a browser on http://localhost:8000/demo/?build=asyncify\u0026config=IDBBatchAtomicVFS\u0026reset\n\nThe 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:\n\n| Parameter | Purpose | Values | Default |\n|----|----|----|----|\n| build | Emscripten build type | default, asyncify, jspi | default |\n| config | select VFS | MemoryVFS, MemoryAsyncVFS, IDBBatchAtomicVFS, IDBMirrorVFS, AccessHandlePoolVFS, OPFSAdaptiveVFS, OPFSAnyContextVFS, OPFSCoopSyncVFS, OPFSPermutedVFS | uses SQLite internal memory |\n| reset | clear persistent storage | | |\n\nFor 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.\n\n## License\nMIT License as of February 10, 2023, changed by generous sponsors\n[Fleet Device Management](https://fleetdm.com/) and [Reflect](https://reflect.app/).\nExisting licensees may continue under the GPLv3 or switch to the new license.\n","funding_links":[],"categories":["JavaScript","Libraries","javascript","webassembly","sqlite"],"sub_categories":["JavaScript / Node.js"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhashimoto%2Fwa-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frhashimoto%2Fwa-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frhashimoto%2Fwa-sqlite/lists"}