You can establish a read-only connection to a DuckDB instance via HTTPS or the S3 API.
This guide requires the httpfs extension, which can be installed using the INSTALL httpfs SQL command. This only needs to be run once.
To connect to a DuckDB database via HTTPS, use the ATTACH statement as follows:
ATTACH 'https://blobs.duckdb.org/databases/stations.duckdb' AS stations_db;
Since DuckDB version 1.1, the
ATTACHstatement creates a read-only connection to HTTP endpoints. In prior versions, it is necessary to use theREAD_ONLYflag.
Then, the database can be queried using:
SELECT count(*) AS num_stations FROM stations_db.stations;
| num_stations |
|---|
| 578 |
To connect to a DuckDB database via the S3 API, configure the authentication for your bucket (if required). Then, use the ATTACH statement as follows:
ATTACH 's3://duckdb-blobs/databases/stations.duckdb' AS stations_db;
Since DuckDB version 1.1, the
ATTACHstatement creates a read-only connection to HTTP endpoints. In prior versions, it is necessary to use theREAD_ONLYflag.
The database can be queried using:
SELECT count(*) AS num_stations FROM stations_db.stations;
| num_stations |
|---|
| 578 |
Connecting to S3-compatible APIs such as the Google Cloud Storage (
gs://) is also supported.
© Copyright 2018–2024 Stichting DuckDB Foundation
Licensed under the MIT License.
https://duckdb.org/docs/guides/network_cloud_storage/duckdb_over_https_or_s3.html