{"_id":"wa-sqlite","name":"wa-sqlite","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"wa-sqlite","version":"1.0.0","type":"module","main":"src/sqlite-api.js","types":"src/types/index.d.ts","scripts":{"build-docs":"typedoc","start":"web-dev-server --node-resolve","test":"karma start karma.conf.cjs --browsers ChromeHeadless","test-manual":"karma start karma.conf.cjs --auto-watch --no-single-run --reporters progress"},"devDependencies":{"@web/dev-server":"^0.1.13","comlink":"^4.4.1","jasmine-core":"^4.5.0","karma":"^6.4.1","karma-chrome-launcher":"^3.1.1","karma-jasmine":"^5.1.0","monaco-editor":"^0.34.1","puppeteer":"^19.6.3","sinon":"^15.0.1","typedoc":"^0.22.11","typescript":"^4.2.4"},"dependenciesMeta":{"comlink@4.4.1":{"unplugged":true},"monaco-editor@0.34.1":{"unplugged":true},"sinon@15.0.1":{"unplugged":true}},"gitHead":"514745479b0a4706793efa0a361c10d899166acd","description":"[![wa-sqlite CI](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml/badge.svg?branch=breaking-changes)](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml?branch=breaking-changes)","_id":"wa-sqlite@1.0.0","_nodeVersion":"16.19.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-Kyybo5/BaJp76z7gDWGk2J6Hthl4NIPsE+swgraEjy3IY6r5zIR02wAs1OJH4XtJp1y3puj3Onp5eMGS0z7nUA==","shasum":"84eb5071becb9ac6ae67cd97633db7fb345e1621","tarball":"https://registry.npmjs.org/wa-sqlite/-/wa-sqlite-1.0.0.tgz","fileCount":41,"unpackedSize":2175986,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFU1Bx1ZDMmH1vcNd1PK3fDgs77QzUwc97c2Ms9M8C4WAiEAybDoWtIPLl+8MybyWRvW58RqLPQJoPKVrj0HnkHF170="}]},"_npmUser":{"name":"gabrieldevunstatic","email":"tailinh@unstatic.co"},"directories":{},"maintainers":[{"name":"gabrieldevunstatic","email":"tailinh@unstatic.co"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/wa-sqlite_1.0.0_1704430349546_0.4131681881686373"},"_hasShrinkwrap":false}},"time":{"created":"2024-01-05T04:52:29.545Z","1.0.0":"2024-01-05T04:52:29.763Z","modified":"2024-01-05T04:52:30.025Z"},"maintainers":[{"name":"gabrieldevunstatic","email":"tailinh@unstatic.co"}],"description":"[![wa-sqlite CI](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml/badge.svg?branch=breaking-changes)](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml?branch=breaking-changes)","readme":"[![wa-sqlite CI](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml/badge.svg?branch=breaking-changes)](https://github.com/rhashimoto/wa-sqlite/actions/workflows/ci.yml?branch=breaking-changes)\n\n# wa-sqlite\nThis is a WebAssembly build of SQLite with experimental support for writing SQLite virtual filesystems and virtual table modules completely in Javascript. This allows alternative browser storage options such as IndexedDB and File System Access. Applications can opt to use either a synchronous or asynchronous (using Asyncify) SQLite library build (an asynchronous build is required for asynchronous extensions).\n\n[IndexedDB](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/IDBMinimalVFS.js) and [Origin Private File System](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/OriginPrivateFileSystemVFS.js) virtual file systems and a [virtual table module that accesses Javascript arrays](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/ArrayModule.js) are among the examples provided as proof of concept.\n\n[Try the demo](https://rhashimoto.github.io/wa-sqlite/demo/) or run [benchmarks](https://rhashimoto.github.io/wa-sqlite/demo/benchmarks.html) 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.25+.\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` (or `yarn prepack`)\n\nThe default build produces ES6 modules + WASM, [synchronous and asynchronous](https://github.com/rhashimoto/wa-sqlite/issues/7) (using Asyncify) 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's 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) => {\n      console.log(row);\n    });\n    await sqlite3.close(db);\n  }\n\n  hello();\n```\n\nThe [implementation of `sqlite3.exec`](https://github.com/rhashimoto/wa-sqlite/blob/b5824ac0031da81712bee42671a917b252737c45/src/sqlite-api.js#L422-L434) 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/\n\nThe demo page provides access to databases on multiple VFS implementations, including IndexedDB (which is the only one persistent across page loads and multiple tabs). In addition, in each database there is a SQLite module named \"array\" that provides some historical stock data from a common Javascript array - use it for virtual tables in SQL like this:\n```sql\nCREATE VIRTUAL TABLE IF NOT EXISTS goog USING array;\n\n-- Use it directly out of the Javascript array:\nSELECT * FROM goog LIMIT 5;\n\n-- Copy into a native table (on the current VFS):\nCREATE TABLE IF NOT EXISTS tbl AS SELECT * FROM goog;\n```\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","readmeFilename":"README.md"}