workers-dbms
v0.0.6
Published
Workers Database Management System for Durable Objects
Downloads
339
Maintainers
Readme
workers-dbms
Workers Database Management System for Durable Objects
Features
- On demand SQLite databases (like neon.tech)
- https endpoints to manage and query databases
- Websocket endpoint to query databases
- Transactions support in websocket mode!
Get started
npm install --save workers-dbms
npm install --save wrangler
Create a index.ts
file with this:
import { generateApp } from "workers-dbms";
export { DBMSDO } from "workers-dbms";
export default generateApp()
Create a wrangler.toml
file with this:
#:schema node_modules/wrangler/config-schema.json
name = "workers-dbms"
main = "index.ts"
compatibility_date = "2024-09-28"
# workers_dev = false # uncomment this for enhanced security !
[[durable_objects.bindings]]
name = "DBSM_DO"
class_name = "DBMSDO"
[[migrations]]
tag = "v1"
new_sqlite_classes = ["DBMSDO"]
Deploy your dbms with wrangler:
wrangler deploy
You can now access your dbms on the worker deployed url
There is also a swagger interface with all the endpoints documented at /api
path.
Supported frameworks
Django
The package django-d1 has an experimental backend to use the websocket endpoint to run django migrations and queries
Example usage in django:
DATABASES = {
'default': {
'ENGINE': 'django_dbms',
'WORKERS_DBMS_ENDPOINT': 'wss://your-endpoint.dev/api/v1/databases/django/websocket',
'WORKERS_DBMS_ACCESS_ID': 'abc.access',
'WORKERS_DBMS_ACCESS_SECRET': 'abcabc',
}
}
Images
Home page
Database details
API Documentation with swagger
FAQ
Handshake status 426 Upgrade Required
When using a custom domain for your worker, make sure to enable WebSockets on the domain Network configuration, otherwise you will not be able to use the websocket endpoint!