← Back to blog
Admin 3 min read

Getting Started with Cloudflare D1: A Visual Guide

D1 gives you a serverless SQLite database on Cloudflare's edge — and you don't need a terminal to use it.

What you'll build in this guide

6 steps Create a D1 database, connect visually, create tables, insert data, query, and edit inline.
Time About 10 minutes, start to finish. No terminal required.
Tools A free Cloudflare account + MyD1 (free, macOS 14+).

Cloudflare D1 is a serverless SQLite database that runs on Cloudflare's global network. If you've used SQLite before, D1 will feel familiar. If you haven't, that's fine too — this guide starts from zero.

We'll create a D1 database, set up tables, insert data, and run queries — using a visual interface instead of the terminal.

What is Cloudflare D1?

D1 is a relational database built on SQLite. It's part of Cloudflare's developer platform, alongside Workers (serverless functions), R2 (object storage), and KV (key-value store). The key features:

Step 1: Create a D1 database

If you don't have a D1 database yet, create one from the Cloudflare dashboard:

  1. Log in to dash.cloudflare.com
  2. Go to Workers & Pages → D1
  3. Click Create database
  4. Give it a name (e.g., my-first-db) and click Create

You can also create one from the terminal with wrangler d1 create my-first-db (see the D1 getting started docs), but we're going visual here.

Step 2: Connect with MyD1

To manage your D1 database visually, download MyD1 and connect it to your Cloudflare account.

  1. Download MyD1 (free, macOS 14+)
  2. Open the app and click + in the sidebar
  3. Choose Cloudflare D1
  4. Enter your Account ID (found in Workers & Pages → Overview → right sidebar)
  5. Enter your API Token (create one at My Profile → API Tokens with D1 edit permissions)
  6. Click Connect

All your D1 databases appear in the sidebar. Click the one you just created.

Step 3: Create your first table

Open the query editor (⌘N) and run this SQL:

CREATE TABLE products (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  name TEXT NOT NULL,
  price REAL NOT NULL,
  category TEXT,
  in_stock INTEGER DEFAULT 1,
  created_at TEXT DEFAULT (datetime('now'))
);

Press ⌘Enter to execute. The table appears in the sidebar. Click it to see the (empty) data grid with all six columns.

Step 4: Insert some data

Back in the query editor, insert a few rows:

INSERT INTO products (name, price, category) VALUES
  ('Mechanical Keyboard', 149.99, 'peripherals'),
  ('USB-C Hub', 59.99, 'accessories'),
  ('Webcam HD', 89.99, 'peripherals'),
  ('Desk Lamp', 34.99, 'office'),
  ('Monitor Stand', 44.99, 'office');

Execute, then click the products table in the sidebar. You'll see all five rows in the data grid, with sortable columns and clearly marked types.

Step 5: Query your data

Try some queries to get a feel for D1's SQL dialect (it's standard SQLite):

-- All products under $50
SELECT * FROM products WHERE price < 50;

-- Count by category
SELECT category, COUNT(*) as count, AVG(price) as avg_price
FROM products
GROUP BY category;

-- Most expensive products first
SELECT name, price FROM products ORDER BY price DESC;

Results appear in a clean grid below the editor. Each query gets its own result tab when you run multiple statements.

Step 6: Edit data inline

Go back to the table view and double-click the price of "USB-C Hub." Change it to 49.99 and press Enter. MyD1 runs the UPDATE statement behind the scenes.

This inline editing is great during development. No need to write UPDATE statements for simple fixes.

Coming from MySQL or PostgreSQL?

A few things work differently in D1 / SQLite:

  • Types are flexible — SQLite uses type affinity, not strict types. A TEXT column can technically store a number.
  • No ALTER TABLE DROP COLUMN in older SQLite versions — D1 uses a recent SQLite version that supports this, but some edge cases may differ.
  • AUTOINCREMENT works like MySQL's AUTO_INCREMENT but uses INTEGER PRIMARY KEY AUTOINCREMENT syntax.
  • No ENUM type — use CHECK constraints instead: category TEXT CHECK(category IN ('a', 'b', 'c'))
  • Datetime — SQLite doesn't have a native datetime type. Store as TEXT (ISO format) or INTEGER (Unix timestamp). See SQLite date functions.

Next steps

You've got a working D1 database with tables, data, and queries. From here:

  • Connect it to a Workerbind your D1 database in wrangler.toml and query it from your Cloudflare Worker
  • Add more tables — create relationships with foreign keys
  • Try the AI assistant — ask questions in plain English and get SQL back (free for all users)
  • Add MySQL, PostgreSQL, or SQLite — MyD1 connects to all four engines from the same sidebar

Download MyD1 to get started — the free version includes everything in this guide.

Next steps: Browse and Query D1 Visually · Build a Full-Stack App on Cloudflare for Free · Managing D1 Without the Terminal