# 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="/pages/CcGKYzNCGcGCT5CYd0Pc"><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="/pages/bcpCwD9uRgWqMXcMQbR7"><strong><code>Workflow.datasource</code></strong></a>(name)</td><td>Create a reference to a Datasource within a specific <a href="/pages/KOkANjKjjVdEbbzoR2nH">workflow</a>. </td></tr><tr><td><a href="/pages/Dy5Q11mnJsbF25p6WZed"><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="/pages/51a65nwmou4Detg7X556"><strong><code>datasource.create</code></strong></a>()</td><td>Create a new datasource in a workflow</td></tr><tr><td><a href="/pages/6Yt6f9xS2f8iNxfj74X2"><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="/pages/vSZAXQJJpzOrKB5dRCop">datasource resource definition</a>. Will raise an error if the datasource does not exist.</td></tr><tr><td><a href="/pages/jLhMjnH4NOqwx1AGzpxf"><strong><code>datasource.exists</code></strong></a>()</td><td>Check whether the datasource exists.</td></tr><tr><td><a href="/pages/gFecZh2mrr3BXVxoY278"><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="/pages/JvBGmTnq3smvq83GjAiX"><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="/pages/Jy0mDFLfm4zcU0IWXYj0"><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: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
