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.
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
); 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⟩');
© Copyright 2018–2024 Stichting DuckDB Foundation
Licensed under the MIT License.
https://duckdb.org/docs/guides/network_cloud_storage/cloudflare_r2_import.html