Visit project on GitHub
Set theme to dark

denoflare d1

Manage and query your Cloudflare D1 databases

--help

$ denoflare d1 --help
denoflare-d1 0.7.0

Manage and query your Cloudflare D1 databases

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

SUBCOMMANDS:
    list                  List databases
    get                   Get database metadata
    drop                  Drop a database
    create                Create a database
    query                 Query a database
    clear                 Clear out a database (drop all objects)
                          
    export                Returns a signed url to the sql contents of a database
    export-sql            Downloads a database as a SQL file
    export-db             Downloads a database as a sqlite3 db file
    import                Imports SQL into a database
    import-tsv            Imports TSV data into a database
                          
    time-travel-bookmark  Obtain a time travel bookmark for a database
    time-travel-restore   Restore a database to a specific timestamp or bookmark

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

Database operations


list

$ denoflare d1 list --help
denoflare-d1-list 0.7.0

List databases

USAGE:
    denoflare d1 list [OPTIONS]

OPTIONS:
    --name <string>        A database name to search for
                           
    --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)

get

$ denoflare d1 get --help
denoflare-d1-get 0.7.0

Get database metadata

USAGE:
    denoflare d1 get <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)

drop

$ denoflare d1 drop --help
denoflare-d1-drop 0.7.0

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.7.0

Create a database

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

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

OPTIONS:
    --location <location>  Hint for the database's primary location (one of: weur, eeur, apac, wnam, enam)
                           
    --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.7.0

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
    --raw                  Returns results as arrays instead of objects, more efficient
                           
    --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)

clear

$ denoflare d1 clear --help
denoflare-d1-clear 0.7.0

Clear out a database (drop all objects)

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

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

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)

Import/export operations


export

$ denoflare d1 backup --help
denoflare-d1-export 0.7.0

Returns a signed url to the sql contents of a database

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

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

OPTIONS:
    --poll                 Incremental polling for progress, useful for larger exports
    --bookmark <string>    Resume polling as of a returned last bookmark
    --no-data              Export only the table definitions, not their contents
    --no-schema            Export only each table's contents, not its definition
    --table <string>...    Filter the export to just one or more tables
                           
    --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)

export-sql

$ denoflare d1 backup --help
denoflare-d1-export-sql 0.7.0

Downloads a database as a SQL file

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

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

OPTIONS:
    --file <string>        Local file path at which to save the export sql file (required)
    --no-data              Export only the table definitions, not their contents
    --no-schema            Export only each table's contents, not its definition
    --table <string>...    Filter the export to just one or more tables
                           
    --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)

export-db

$ denoflare d1 backup --help
denoflare-d1-export-db 0.7.0

Downloads a database as a sqlite3 db file

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

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

OPTIONS:
    --file <string>        Local file path at which to save the export sqlite3 db file (required)
    --no-data              Export only the table definitions, not their contents
    --no-schema            Export only each table's contents, not its definition
    --table <string>...    Filter the export to just one or more tables
                           
    --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)

import

$ denoflare d1 backup --help
denoflare-d1-import 0.7.0

Imports SQL into a database

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

ARGS:
    <database-name>        Name of the database to import into

OPTIONS:
    --file <string>        Local sql file to import (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)

import-tsv

$ denoflare d1 backup --help
denoflare-d1-import-tsv 0.7.0

Imports TSV data into a database

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

ARGS:
    <database-name>        Name of the database to import into

OPTIONS:
    --file <string>        Local TSV file to import (required)
    --table <string>       D1 table name (required)
    --pk <string>          Name of the primary key column
    --no-rowid             Create the table without rowid
    --max-rows <integer>   Only import the first n data rows (not counting the header)
    --skip-rows <integer>  Skip the first n data rows (not counting the header)
                           
    --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)

Time-travel operations


time-travel-bookmark

$ denoflare d1 backup --help
denoflare-d1-time-travel-bookmark 0.7.0

Obtain a time travel bookmark for a database

USAGE:
    denoflare d1 time-travel-bookmark <database-name> [OPTIONS]

ARGS:
    <database-name>        Name of the database

OPTIONS:
    --timestamp <string>   ISO time of the database state
                           
    --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)

time-travel-restore

$ denoflare d1 backup --help
denoflare-d1-time-travel-restore 0.7.0

Restore a database to a specific timestamp or bookmark

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

ARGS:
    <database-name>        Name of the database

OPTIONS:
    --timestamp <string>   ISO time of the database state
    --bookmark <string>    A specific bookmark
                           
    --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)