Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rkusa/wasm-sqlite
[Experimental] SQLite compiled to WASM with pluggable page storage.
https://github.com/rkusa/wasm-sqlite
sqlite vfs wasm
Last synced: 5 days ago
JSON representation
[Experimental] SQLite compiled to WASM with pluggable page storage.
- Host: GitHub
- URL: https://github.com/rkusa/wasm-sqlite
- Owner: rkusa
- Created: 2022-01-25T14:06:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-06T16:33:05.000Z (almost 2 years ago)
- Last Synced: 2024-11-08T03:03:26.412Z (7 days ago)
- Topics: sqlite, vfs, wasm
- Language: Rust
- Homepage:
- Size: 41 KB
- Stars: 49
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `wasm-sqlite`
SQLite compiled to WASM with pluggable data storage. Useful to save SQLite in e.g. Cloudflare Durable Objects (example: https://github.com/rkusa/do-sqlite).
**Status:** This is very experimental. Don't use it for real applications yet! See the [conclusion of my blog post](https://ma.rkusa.st/store-sqlite-in-cloudflare-durable-objects#conclusion) for reasons for why not to use it.
```bash
npm install -S @rkusa/wasm-sqlite
```## Example
```ts
const sqlite = await Sqlite.instantiate({
pageCount(): number {
return self.pageCount;
},async getPage(ix: number): Promise {
return (await storage.get(ix)) ?? new Uint8Array(4096);
},async putPage(ix: number, page: Uint8Array): Promise {
await storage.put(ix, page);
},async delPage(ix: number): Promise {
await storage.delete(ix);
if (ix + 1 >= self.pageCount) {
self.pageCount = ix;
}
},
});const conn = await this.sqlite.connect();
await conn.execute("...", []);
const query: T = await conn.query("...", []);
```## Build
Execute the following once:
```bash
brew install cmake ninja binaryen
./build-wasi-sdk.sh
```After that, build it via:
```bash
npm run build
```