Visit project on GitHub
Set theme to dark

denoflare d1

Manage and query your Cloudflare D1 databases

--help

$ denoflare d1 --help
denoflare-d1 0.5.6

Manage and query your Cloudflare D1 databases

USAGE:
    denoflare d1 <subcommand> <args> <options>

SUBCOMMANDS:
    list          List databases
    drop          Drop a database
    create        Create a database
    query         Query a database
                  
    backup        Backup a database
    restore       Restore a database from a previous backup
    download      Download a database as a sqlite3 db file
    list-backups  List all backups for a database

For subcommand-specific help: denoflare d1 <subcommand> --help

Database operations


list

$ denoflare d1 list --help
denoflare-d1-list 0.5.6

List databases

USAGE:
    denoflare d1 list [OPTIONS]

OPTIONS:
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)

drop

$ denoflare d1 drop --help
denoflare-d1-drop 0.5.6

Drop a database

USAGE:
    denoflare d1 drop <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database to drop

OPTIONS:
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)

create

$ denoflare d1 create --help
denoflare-d1-create 0.5.6

Create a database

USAGE:
    denoflare d1 create <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database to create

OPTIONS:
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)

query

$ denoflare d1 query --help
denoflare-d1-query 0.5.6

Query a database

USAGE:
    denoflare d1 query <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database to query

OPTIONS:
    --sql <string>         SQL query to execute
    --param <value>...     Ordinal parameters for the query
                           
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)

Database backup operations


backup

$ denoflare d1 backup --help
denoflare-d1-backup 0.5.6

Backup a database

USAGE:
    denoflare d1 backup <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database to backup

OPTIONS:
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)

restore

$ denoflare d1 restore --help
denoflare-d1-restore 0.5.6

Restore a database from a previous backup

USAGE:
    denoflare d1 restore <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database to backup

OPTIONS:
    --backup-id <string>   Uuid of the backup to restore (required)
                           
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)

download

$ denoflare d1 download --help
denoflare-d1-download 0.5.6

Download a database as a sqlite3 db file

USAGE:
    denoflare d1 download <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database to download

OPTIONS:
    --file <string>        Local file path at which to save the sqlite db file (required)
    --backup-id <string>   Uuid of the backup to download (default: take a new backup and download that)
                           
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)

For example, to download the current state of my-database and save as a local file named my-database.db

$ denoflare d1 backup my-database --file my-database.db
Backup 00e3344b-176e-4dfd-9f51-b89db3c39056 (12kb) took 3475ms
Download of backup 00e3344b-176e-4dfd-9f51-b89db3c39056 (12kb) took 555ms
Saved to /Users/me/path/to/cwd/my-database.db

list-backups

$ denoflare d1 list-backups --help
denoflare-d1-list-backups 0.5.6

List all backups for a database

USAGE:
    denoflare d1 list-backups <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database

OPTIONS:
    --config <path>        Path to config file (default: .denoflare in cwd or parents)
    --profile <name>       Explicit profile to use from config file
    --account-id <string>  Explicit Cloudflare account id to use for authentication
    --api-token <string>   Explicit Cloudflare API token to use for authentication
                           
    --help                 Print help information
    --verbose              Toggle verbose output (when applicable)