Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rkusa/do-sqlite
[Experimental] Persist SQLite in a Cloudflare Durable Object
https://github.com/rkusa/do-sqlite
cloudflare durable-objects sqlite wasm
Last synced: about 2 months ago
JSON representation
[Experimental] Persist SQLite in a Cloudflare Durable Object
- Host: GitHub
- URL: https://github.com/rkusa/do-sqlite
- Owner: rkusa
- Created: 2022-01-13T20:51:16.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-11-11T16:17:32.000Z (about 1 year ago)
- Last Synced: 2024-04-09T21:13:03.119Z (9 months ago)
- Topics: cloudflare, durable-objects, sqlite, wasm
- Language: TypeScript
- Homepage: https://ma.rkusa.st/store-sqlite-in-cloudflare-durable-objects
- Size: 2.54 MB
- Stars: 129
- Watchers: 6
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# `do-sqlite`
[Experimental] POC that persists SQLite in a Cloudflare Durable Object.
My journey of creating it: https://ma.rkusa.st/store-sqlite-in-cloudflare-durable-objects
## Next Steps
- [ ] Add support for persistent journal files (to prevent data loss and database corruption)
- [ ] Add proper error handling
- [ ] Ensure that everything works fine when the DO is used concurrently## Usage
Deploy to Cloudflare (you might have to get a script limit increase to be able to deploy it):
```bash
wrangler publish
```Execute a query (path pattern: `/:database/{query,execute}`):
```bash
curl -i -X POST -H 'Content-Type: application/json' \
-d '{"sql":"CREATE TABLE vals (id INTEGER PRIMARY KEY AUTOINCREMENT, val VARCHAR NOT NULL)"}' \
https://do-sqlite.YOUR_WORKERS.workers.dev/main/execute
``````bash
curl -i -X POST -H 'Content-Type: application/json' \
-d '{"sql":"INSERT INTO vals (val) VALUES (?1)","params":["val"]}' \
https://do-sqlite.YOUR_WORKERS.workers.dev/main/execute
``````bash
curl -i -X POST -H 'Content-Type: application/json' \
-d '{"sql":"SELECT * FROM vals"}' \
https://do-sqlite.YOUR_WORKERS.workers.dev/main/query
```