Guides
Attaching to a Database over the S3 API
To connect to a DuckDB database via the S3 API, [configure the authentication](#docs:guides:network_cloud_storage:s3_import::credentials-and-configuration) for your bucket (if required).
Then, use the [`ATTACH` statement](#docs:sql:statements:attach) as follows:  
```sql
ATTACH 's3://duckdb-blobs/databases/stations.duckdb' AS stations_db;
```  
> Since DuckDB version 1.1, the `ATTACH` statement creates a read-only connection to HTTP endpoints.
> In prior versions, it is necessary to use the `READ_ONLY` flag.  
The database can be queried using:  
```sql
SELECT count(*) AS num_stations
FROM stations_db.stations;
```  
| num_stations |
|-------------:|
| 578          |  
> Connecting to S3-compatible APIs such as the [Google Cloud Storage (` gs://`)](#docs:guides:network_cloud_storage:gcs_import::attaching-to-a-database) is also supported.