Download Import Script

Download our Cloudflare D1 import script:

curl -O https://app.chartdb.io/bash-scripts/cloudflare-d1-import.sh
chmod +x cloudflare-d1-import.sh

Usage

Run the script with your Cloudflare D1 database name and ChartDB information:

./cloudflare-d1-import.sh \
  -d your-database-name \
  -a your-chartdb-api-key \
  -t your-diagram-id

For remote databases, add the -r flag:

./cloudflare-d1-import.sh \
  -d your-database-name \
  -a your-chartdb-api-key \
  -t your-diagram-id \
  -r

Required Parameters

  • -d Cloudflare D1 database name
  • -a ChartDB API key
  • -t Target diagram ID

Optional Parameters

  • -r Use remote database (if not specified, uses local database)

The script will connect to your Cloudflare D1 database, extract the schema, and automatically import it into your ChartDB diagram.

Automated Daily Updates

To automatically update your diagram daily using cron, add the following line to your crontab:

# Run at 2 AM every day
0 2 * * * /path/to/cloudflare-d1-import.sh -d database_name -a api_key -t diagram_id >> /path/to/d1-import.log 2>&1

To edit your crontab:

crontab -e

Note: Replace /path/to/cloudflare-d1-import.sh with the absolute path to the script and adjust the database name accordingly. The log file path (/path/to/d1-import.log) should be in a directory where your user has write permissions.