---
title: "Data Platform Buckets connector"
description: "In the current Data Platform SDK, the Datastore connector is used to interact with the Data Platform Buckets"
url: https://docs.ovhcloud.com/pt/guides/public-cloud/data-platform/developers-python-sdk-connect-bucket
lang: pt
lastUpdated: 2026-09-14
---
> For AI agents: the complete documentation index is available at https://docs.ovhcloud.com/pt/llms.txt, the full documentation bundle is available at https://docs.ovhcloud.com/pt/llms-full.txt.

# Data Platform Buckets connector

## Objective

:::info
In the current Data Platform SDK, the **Datastore connector** is used to interact with the Data Platform Buckets. You may think of the Datastore simply as a bucket container.
:::

## Connect to the Datastore

In order to interact with the Datastore you have to connect to it first, as shown in the code below:

```python
from forepaas.dwh import connect

cn_datastore = connect('data_store')
```

After that you can use the `cn_datastore.list()` method to see the buckets available in your Datastore and then connect to the bucket of your choice to interact with it.

You can connect directly to a specific bucket in the Datastore as shown in the code below:

```python
from forepaas.dwh import connect

bucket_name = "name"
cn_bucket = connect('data_store/' + bucket_name)
```

The datastore connector will return a Data Store Connector object and connecting directly to a bucket will return a Bucket Connector object.

See the next section of this article for additional details on the methods of each connector.

## Datastore Connector methods

### datastore.list(return\_type = 'array')

Lists all buckets in the Datastore.

**Input Parameters**

| Name         | Type | Description                                         | Example |
| :----------- | :--: | :-------------------------------------------------- | :------ |
| return\_type |  str | Determine the type you want to get `array` or `str` |         |

**Output**

|       Type       | Description                   | Example |
| :--------------: | :---------------------------- | :------ |
| `str` or `array` | List of buckets in Data Store |         |

### datastore.get\_buckets()

Gets all buckets from the Datastore

**Output**

|      Type      | Description                | Example |
| :------------: | :------------------------- | :------ |
| `list[bucket]` | list of `bucket` instances |         |

### datastore.get\_bucket(name)

Gets a bucket instance from its name.

**Input Parameters**

| Name | Type | Description | Example |
| :--- | :--: | :---------- | :------ |
| name |  str | Bucket name |         |

**Output**

|   Type   | Description                     | Example |
| :------: | :------------------------------ | :------ |
| `bucket` | Bucket instance to handle files |         |

### datastore.create\_bucket(name)

Adds a bucket in the Data Store.

**Input Parameters**

| Name | Type | Description | Example |
| :--- | :--: | :---------- | :------ |
| name |  str | Bucket name |         |

**Output**

|    Type   | Description          | Example |
| :-------: | :------------------- | :------ |
| `boolean` | Success of operation |         |

### datastore.remove\_bucket(name)

Removes a bucket from the Data Store.

**Input Parameters**

| Name | Type | Description | Example |
| :--- | :--: | :---------- | :------ |
| name |  str | Bucket name |         |

**Output**

|    Type   | Description          | Example |
| :-------: | :------------------- | :------ |
| `boolean` | Success of operation |         |

### datastore.bucket\_exists(name)

Finds out if a bucket exists or not.

**Input Parameters**

| Name | Type | Description | Example |
| :--- | :--: | :---------- | :------ |
| name |  str | Bucket name |         |

**Output**

|    Type   | Description          | Example |
| :-------: | :------------------- | :------ |
| `boolean` | Success of operation |         |

## Bucket Connector methods

### bucket.list(bool metadata=True, bool recursive=True, \*\*kwargs)

Lists files from Data Store's bucket.

**Input Parameters**

| Name       | Type | Description                                      | Example |
| ---------- | ---- | ------------------------------------------------ | ------- |
| metadata   | bool | (optional) Get metadata for all files listed     | True    |
| recursive  | bool | (optional) List recursively through folders      | True    |
| \*\*kwargs |      | Additional arguments passed to list\_objects\_v2 |         |

**Output**

| Type          | Description          | Example |
| ------------- | -------------------- | ------- |
| list\[Object] | List of bucket files |         |

**Short Example**

```python
from forepaas.dwh.connect import connect
import logging

bucket_name = "name"
bucket = connect('data_store/' + bucket_name)
files = bucket.list()
logger.info(f"Bucket contents: {files}")
```

### bucket.list\_filename(return\_type='array', contains='', recursive=True, \*\*kwargs)

Lists filenames from Data Store's bucket.

**Input Parameters**

| Name         | Type | Description                                      | Example |
| ------------ | ---- | ------------------------------------------------ | ------- |
| return\_type | str  | Return type format: 'array' or 'str'             | 'array' |
| contains     | str  | Filter filenames containing this value           | '2023'  |
| recursive    | bool | (optional) List recursively through folders      | True    |
| \*\*kwargs   |      | Additional arguments passed to list\_objects\_v2 |         |

**Output**

| Type          | Description                 | Example        |
| ------------- | --------------------------- | -------------- |
| str or \[str] | List of filenames in bucket | \['file1.csv'] |

**Short Example**

```python
filenames = bucket.list_filename()
logger.info(f"Filenames: {filenames}")
```

### bucket.get(file\_name, \*\*kwargs)

Gets raw file content from a Data Store bucket.

**Input Parameters**

| Name       | Type | Description                  | Example         |
| ---------- | ---- | ---------------------------- | --------------- |
| file\_name | str  | Name of the file to retrieve | "data/file.csv" |

**Output**

| Type                          | Description                  |
| ----------------------------- | ---------------------------- |
| urllib3.response.HTTPResponse | HTTP response with file data |

**Short Example**

```python
file_data = bucket.get('uploads/file.csv')
logger.info(f"Stream: {file_data.stream(1024)}")
```

### bucket.fget(object\_name, file\_path, \*\*kwargs)

Gets an object from Datastore's bucket to local path.

**Input Parameters**

| Name         | Type | Description                         | Example                |
| ------------ | ---- | ----------------------------------- | ---------------------- |
| object\_name | str  | Name of the object in the bucket    | "data.csv"             |
| file\_path   | str  | Local path where file will be saved | "./downloads/data.csv" |

**Output**

| Type   | Description             |
| ------ | ----------------------- |
| Object | Object stat information |

**Short Example**

```python
bucket.fget("uploads/file.csv", "/tmp/file.csv")
logger.info("File downloaded to /tmp/file.csv")
```

### bucket.put(object\_name, data, int length, \*\*kwargs)

Puts an object to Data Store's bucket.

**Input Parameters**

| Name         | Type         | Description               | Example        |
| ------------ | ------------ | ------------------------- | -------------- |
| object\_name | str          | Name to assign the object | "uploaded.csv" |
| data         | io.RawIOBase | Data stream               | stream         |
| length       | int          | Length of the data        | 2048           |

**Output**

| Type | Description             |
| ---- | ----------------------- |
| str  | Object ETag from server |

**Short Example**

```python
import io
data = io.BytesIO(b"name,age\nJohn,30")
etag = bucket.put("people.csv", data, data.getbuffer().nbytes)
logger.info(f"Uploaded with ETag: {etag}")
```

### bucket.fput(object\_name, file\_path, \*\*kwargs)

Puts a file to Data Store's bucket.

**Input Parameters**

| Name         | Type | Description                      | Example        |
| ------------ | ---- | -------------------------------- | -------------- |
| object\_name | str  | Name of object to be created     | "backup.csv"   |
| file\_path   | str  | Path to the file on local system | "./backup.csv" |

**Output**

| Type | Description             |
| ---- | ----------------------- |
| str  | Object ETag from server |

**Short Example**

```python
bucket.fput("people.csv", "/tmp/people.csv")
logger.info("Uploaded /tmp/people.csv")
```

### bucket.put\_request(url, path, data=\{}, method='GET', headers=\{}, \*\*kwargs)

Gets an object from an HTTP request and upload it to Datastore's bucket.

**Input Parameters**

| Name    | Type | Description                            | Example          |
| ------- | ---- | -------------------------------------- | ---------------- |
| url     | str  | Source URL to download the object from | "https\://..."   |
| path    | str  | Path to store the file in the bucket   | "raw/data.csv"   |
| data    | dict | Request body data (if any)             | \{}              |
| method  | str  | HTTP method to use                     | 'GET'            |
| headers | dict | Custom headers for the request         | \{'Auth': '...'} |

**Short Example**

```python
bucket.put_request(
    url="https://example.com/file.csv",
    path="remote/file.csv"
)
logger.info("File fetched from URL and uploaded to bucket.")
```

### bucket.delete(path, \*\*kwargs)

Deletes multiple/single file in Data Store's bucket.

**Input Parameters**

| Name | Type        | Description                  | Example         |
| ---- | ----------- | ---------------------------- | --------------- |
| path | str or list | Path(s) of file(s) to delete | "data/file.csv" |

**Short Example**

```python
bucket.delete("people.csv")
logger.info("File deleted from bucket.")
```

### bucket.fcopy\_to(new\_bucket, object\_name, object\_source, \*\*kwargs)

Copies file from bucket to a new bucket in Data Store.

**Input Parameters**

| Name           | Type | Description                              | Example            |
| -------------- | ---- | ---------------------------------------- | ------------------ |
| new\_bucket    | str  | Target bucket name                       | "archive"          |
| object\_name   | str  | New name for the copied object           | "file\_backup.csv" |
| object\_source | str  | Original object's name in current bucket | "file.csv"         |

**Short Example**

```python
bucket.fcopy_to("archive", "people_backup.csv", "people.csv")
logger.info("File copied to archive bucket.")
```

### bucket.exists(filename, \*\*kwargs)

Checks whether a file exists in the bucket.

**Input Parameters**

| Name       | Type | Description                            | Example         |
| ---------- | ---- | -------------------------------------- | --------------- |
| filename   | str  | Name or path of the file to check      | "logs/2024.csv" |
| `**kwargs` |      | Additional options for internal checks |                 |

**Output**

| Type | Description             |
| ---- | ----------------------- |
| bool | Whether the file exists |

**Short Example**

```python
if bucket.exists("people.csv"):
    logger.info("File exists.")
```

### bucket.get\_content(file\_name, \*\*kwargs)

Retrieves the full content of a file from the bucket.

**Input Parameters**

| Name       | Type | Description                        | Example      |
| ---------- | ---- | ---------------------------------- | ------------ |
| file\_name | str  | Name of the file in the bucket     | "people.csv" |
| `**kwargs` |      | Additional options (e.g., version) |              |

**Output**

| Type        | Description             |
| ----------- | ----------------------- |
| bytes / str | Raw content of the file |

**Short Example**

```python
content = bucket.get_content("people.csv")
logger.info(f"File content: {content.decode()}")
```

### bucket.get\_path(path)

Returns the full qualified path (URL or reference) of an object in the bucket.

**Input Parameters**

| Name | Type | Description                   | Example               |
| ---- | ---- | ----------------------------- | --------------------- |
| path | str  | Path or object name in bucket | "reports/summary.csv" |

**Output**

| Type | Description             |
| ---- | ----------------------- |
| str  | Full path to the object |

**Short Example**

```python
full_path = bucket.get_path("people.csv")
logger.info(f"Full path: {full_path}")
```

### bucket.remove\_path(path)

Removes a specific path from the bucket.

**Input Parameters**

| Name | Type | Description                      | Example            |
| ---- | ---- | -------------------------------- | ------------------ |
| path | str  | Path to the object to be removed | "uploads/file.csv" |

**Output**

| Type | Description            |
| ---- | ---------------------- |
| bool | Success of the removal |

**Short Example**

```python
bucket.remove_path("people.csv")
logger.info("Removed specific path from bucket.")
```

## Deprecated Methods

:::info
The `bucket.stat()` method is no longer supported and has been deprecated. Use `exists()` or `get_content()` as alternatives depending on your use case.
:::

## Additional methods

The Data Platform Datastore is built on [Minio](https://min.io/) technology. Please refer to the [Minio Technical Documentation](https://docs.min.io/docs/python-client-api-reference.html) for more information on the advanced settings of the SDK functions.

## Go further

If you need training or technical assistance to implement our solutions, contact your sales representative or click on [this link](https://www.ovhcloud.com/pt/professional-services/) to get a quote and ask our Professional Services experts for a custom analysis of your project.

Ask questions, give your feedback and interact directly with the team building the Data Platform on the dedicated [Discord channel](https://discord.gg/ovhcloud).

If you need support with your OVHcloud services, create a request in our [Help Centre](https://help.ovhcloud.com/csm?id=csm_get_help).

Join our [community of users](https://community.ovhcloud.com/).
