JacobLinCool / d1-manager

D1 Manager is a web UI and API for Cloudflare D1, a serverless SQL database. It provides a web interface for managing databases, tables, and records, as well as an AI assistant to help you write query in natural language.
https://d1-manager.pages.dev
MIT License
433 stars 209 forks source link
cloudflare-pages d1 database gpt sql

D1 Manager

D1 Manager is a web UI and API for Cloudflare D1, a serverless SQL database. It provides a user-friendly interface for managing databases, tables, and records, as well as an API for performing operations programmatically. D1 Manager simplifies database management, enabling users to focus on their data.

semantic-query-demo

Features

Setup

  1. Fork this repo
  2. Setup a Cloudflare Pages with the forked repo
    • Select the SveltKit framework preset.
    • Build command: npm run build
    • Build output directory: .svelte-kit/cloudflare
  3. Use Cloudflare Access to protect the your site
    • The default access rules only restrict access to preview pages, so make sure to add other urls you want protected.
  4. Bind databases to DB_* environment variables

bind-d1

Note: You can bind multiple databases to the manager. In theis example, DB will be default in the UI, and DB_test will be test.

Environment Variables

Some plugins (e.g. Semantic Query) require additional environment variables to be set.

set-env-var

Also, there are some configuration options that can be set through environment variables.

Semantic Query

You can use OpenAI API or Cloudflare AI Worker to run Semantic Query.

OpenAI API:

Cloudflare AI Worker:

Screenshots

tables

run-query

table-browser

add-record

semantic-query

Semantic Query uses OpenAI GPT-3.5 Turbo to translate natural language queries into SQL.