Skip to content

Instantly share code, notes, and snippets.

@johnspurlock-skymethod
Created September 11, 2024 16:44
Show Gist options
  • Save johnspurlock-skymethod/2e3f1a1d9762f8034d622a53ca7aa1a2 to your computer and use it in GitHub Desktop.
Save johnspurlock-skymethod/2e3f1a1d9762f8034d622a53ca7aa1a2 to your computer and use it in GitHub Desktop.
Export a D1 database to a local sqlite3 db file

New one-liner command to download a Cloudflare D1 database to a local sqlite db file.

Prerequisites:

Install the latest Denoflare CLI (newest commit, not release-tagged yet) if not already installed

  • Install deno if not already installed
  • Then install Denoflare: deno install -A --name denoflare --force https://raw.githubusercontent.com/skymethod/denoflare/66b741c9242e724adbf030a2be26af4b58432631/cli/cli.ts

Run the new denoflare d1 export-db command

denoflare d1 export-db your-d1-database-name --file /path/to/exported.db

Denoflare uses the standard CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN env vars, or explicit command options (see denoflare d1 export-db for help), or a local config file to authenticate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment