⌘+k ctrl+k
1.1.3 (stable)
Search Shortcut cmd + k | ctrl + k
Cloudflare R2 Import

Prerequisites

For Cloudflare R2, the S3 Compatibility API allows you to use DuckDB's S3 support to read and write from R2 buckets.

This requires the httpfs extension, which can be installed using the INSTALL SQL command. This only needs to be run once.

Credentials and Configuration

You will need to generate an S3 auth token and create an R2 secret in DuckDB:

CREATE SECRET (
    TYPE R2,
    KEY_ID 'AKIAIOSFODNN7EXAMPLE',
    SECRET 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
    ACCOUNT_ID 'your-account-id-here' -- your 33 character hexadecimal account ID
);

Querying

After setting up the R2 credentials, you can query the R2 data using DuckDB's built-in methods, such as read_csv or read_parquet:

SELECT * FROM read_parquet('r2://⟨r2_bucket_name⟩/⟨file⟩');