Open source, scale-to-zero, HTTP SQLite database built on top of Cloudflare Durable Objects.
- HTTPS Endpoints to interact with your database
- Transactions Support for ACID database interactions
- Scale-to-zero Compute when your database is not in use
Deploying a new SQLite database instance to a Cloudflare Durable Object can be done in a matter of minutes:
- Clone this repository:
git clone [email protected]:Brayden/starbasedb.git
- Update the
AUTHORIZATION_TOKEN
value in thewrangler.toml
file to be a private value shared only with those who should have access to your database, treat it like an API token. - Run the typegen command:
npm run cf-typegen
- Deploy your worker:
npm run deploy
After your worker has been deployed, you'll receive a console message similar to the one below:
Total Upload: 4.59 KiB / gzip: 1.67 KiB
Your worker has access to the following bindings:
- Durable Objects:
- DATABASE_DURABLE_OBJECT: DatabaseDurableObject
- Vars:
- AUTHORIZATION_TOKEN: "ABC123"
Uploaded starbasedb (2.94 sec)
Deployed starbasedb triggers (0.20 sec)
https://starbasedb.YOUR-ID-HERE.workers.dev
Current Version ID: d3e00de3-56b4-48b9-938d-a7cad57bb66a
Start executing queries against your database with the following cURL commands:
curl --location --request POST 'https://starbasedb.YOUR-ID-HERE.workers.dev/query' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ABC123' \
--data-raw '{
"sql": "CREATE TABLE IF NOT EXISTS artist(artistid INTEGER PRIMARY KEY, artistname TEXT);"
}'
curl --location --request POST 'https://starbasedb.YOUR-ID-HERE.workers.dev/query' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ABC123' \
--data-raw '{
"sql": "INSERT INTO artist (artistid, artistname) VALUES (123, '\''Alice'\''), (456, '\''Bob'\''), (789, '\''Charlie'\'');"
}'
curl --location --request POST 'https://starbasedb.YOUR-ID-HERE.workers.dev/query' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ABC123' \
--data-raw '{
"sql": "SELECT * FROM artist WHERE artistid=$1;",
"params": [123]
}'
curl --location --request POST 'https://starbasedb.YOUR-ID-HERE.workers.dev/query' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ABC123' \
--data-raw '{
"transaction": [
{
"sql": "SELECT * FROM artist WHERE artistid=$1;",
"params": [123]
},
{
"sql": "SELECT * FROM artist;",
"params": []
}
]
}'
curl --location --request POST 'https://starbasedb.YOUR-ID-HERE.workers.dev/query/raw' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ABC123' \
--data-raw '{
"sql": "SELECT * FROM artist;",
"params": []
}'
We welcome contributions! Please refer to our Contribution Guide for more details.
We want to give back to the community and make it simple to deploy your own scale-to-zero SQLite database. With the serverless architecture of durable objects, you can now have your application layer coexist on the same compute instance as your database.
This project is licensed under the MIT license. See the LICENSE file for more info.