DuckDB
Below is an example of using DuckDB ↗ to connect to R2 Data Catalog (read-only). For more information on connecting to R2 Data Catalog with DuckDB, refer to DuckDB documentation ↗.
- Sign up for a Cloudflare account ↗.
- Create an R2 bucket and enable the data catalog.
- Create an R2 API token with both R2 and data catalog permissions.
- Install DuckDB ↗.
- Note: DuckDB 1.3.0 ↗ or greater is required to attach Iceberg REST Catalogs ↗.
In the DuckDB CLI ↗ (Command Line Interface), run the following commands:
-- Install the iceberg DuckDB extension (if you haven't already) and load the extension.INSTALL iceberg;LOAD iceberg;
-- Create a DuckDB secret to store R2 Data Catalog credentials.CREATE SECRET r2_secret ( TYPE ICEBERG, TOKEN '<token>');
-- Attach R2 Data Catalog with the following ATTACH statement (read-only).ATTACH '<warehouse_name>' AS my_r2_catalog ( TYPE ICEBERG, ENDPOINT '<catalog_uri>');
-- Show all available tables.SHOW ALL TABLES;
-- Query your Iceberg table.SELECT * FROM my_r2_catalog.default.my_iceberg_table;
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark