> For the complete documentation index, see [llms.txt](https://docs.redivis.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.redivis.com/api/client-libraries/redivis-python/reference/datasource.md).

# Datasource

## *class* <mark style="color:purple;">Datasource</mark>

An interface for working with workflow datasources on Redivis.

## Constructors

<table data-header-hidden><thead><tr><th width="368">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="/api/client-libraries/redivis-python/reference/redivis/redivis.datasource.md"><strong><code>redivis.datasource</code></strong></a>(name)</td><td>Create a reference to a datasource. Can only be called if a default workflow is set.</td></tr><tr><td><a href="/api/client-libraries/redivis-python/reference/workflow/workflow.datasource.md"><strong><code>Workflow.datasource</code></strong></a>(name)</td><td>Create a reference to a Datasource within a specific <a href="/api/client-libraries/redivis-python/reference/workflow.md">workflow</a>. </td></tr><tr><td><a href="/api/client-libraries/redivis-python/reference/workflow/workflow.list_transforms.md"><strong><code>Workflow.list_datasources</code></strong></a>([max_results])</td><td>Returns a list of Datasources within a workflow</td></tr></tbody></table>

## Examples

```python
username = "imathews"
workflow_name = "example_workflow_climate_analysis:x7kh"
dataset_name = "ghcn_daily_weather_data"

workflow = redivis.workflow(f"{username}.{workflow_name}")
datasource = workflow.datasource(dataset_name)

datasource.update(version="v2.0")
```

## Attributes

| **`workflow`**   | A reference to the [Workflow](/api/client-libraries/redivis-python/reference/workflow.md) instance that this datasource belongs to.                                                                                                        |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **`properties`** | A dict containing the [API resource representation of the datasource](/api/resource-definitions/datasource.md). This will only be populated after certain methods are called, particularly the `get` method, and will otherwise be `None`. |

## Methods

<table data-header-hidden><thead><tr><th width="368">Method</th><th>Description</th></tr></thead><tbody><tr><td><a href="/api/client-libraries/redivis-python/reference/datasource/datasource.create.md"><strong><code>datasource.create</code></strong></a>()</td><td>Create a new datasource in a workflow</td></tr><tr><td><a href="/api/client-libraries/redivis-python/reference/datasource/datasource.get.md"><strong><code>datasource.get</code></strong></a>()</td><td>Fetches the datasource, after which datasource.properties will contain a dict with entries corresponding to the properties on the <a href="/api/resource-definitions/datasource.md">datasource resource definition</a>. Will raise an error if the datasource does not exist.</td></tr><tr><td><a href="/api/client-libraries/redivis-python/reference/datasource/datasource.exists.md"><strong><code>datasource.exists</code></strong></a>()</td><td>Check whether the datasource exists.</td></tr><tr><td><a href="/api/client-libraries/redivis-python/reference/datasource/datasource.source_dataset.md"><strong><code>datasource.source_dataset</code></strong></a>()</td><td>Returns a reference to this datasource's source dataset.</td></tr><tr><td><a href="/api/client-libraries/redivis-python/reference/datasource/datasource.source_workflow.md"><strong><code>datasource.source_workflow</code></strong></a>()</td><td>Returns a reference to this datasource's source workflow.</td></tr><tr><td><a href="/api/client-libraries/redivis-python/reference/datasource/datasource.update.md"><strong><code>datasource.update</code></strong></a>([*, ...])</td><td>Update the datasource to reference a new dataset, workflow, or version thereof.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.redivis.com/api/client-libraries/redivis-python/reference/datasource.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
