Skip to content

Cloudflare D1 ​

Cloudflare D1 is the serverless SQLite database of Cloudflare Workers. DevDb opens local and remote D1 databases.

DatabaseWhere DevDb finds itLicense
D1 (local)wrangler.json, wrangler.jsonc or wrangler.toml with d1_databasesFree
D1 (remote)Remote connection: account ID, database ID and API tokenPro

D1 (local) ​

wrangler dev and wrangler d1 ... --local keep a local SQLite copy of each D1 database. DevDb opens these files with zero-config detection.

DevDb:

  1. Reads the d1_databases bindings from wrangler.json, wrangler.jsonc or wrangler.toml.
  2. Looks for the local file of each binding in .wrangler/state/v3/d1/miniflare-D1DatabaseObject/.
  3. Also looks in the --persist-to folder, if a script in package.json sets one.

Each binding shows under Local Databases as Cloudflare D1 (local) — <binding> binding. DevDb also lists local files that no binding maps to.

No local database yet ​

If a binding has no local file, DevDb tells you to create it. Run one of these commands, then refresh DevDb:

bash
wrangler d1 migrations apply <database> --local
wrangler dev

Changes in DevDb go to the local file only. They do not change the remote database.

D1 (remote) ​

Pro

DevDb connects to a D1 database in your Cloudflare account through the Cloudflare REST API.

  1. Under Remote Connections, click Add, then select Cloudflare D1.
  2. Enter the details:
FieldDescription
Account IDYour Cloudflare account ID
Database IDThe database_id of the D1 database. DevDb offers the database_id values from your Wrangler configuration.
API TokenA Cloudflare API token with D1 permission
  1. Click Test, then click Connect.

API token permission ​

PermissionAccess
D1 ReadRead-only
D1 EditRead and change data

Use D1 Read when you only look at data. DevDb keeps the token in the secret storage of your editor.

WARNING

Remote D1 is your deployed data. Changes in DevDb change the data that your Worker uses.

MCP ​

MCP queries on D1 are read-only unless Devdb.mcp.allowWrites is on.

DevDb - Zero-config database client for VS Code