# hooks

The second required parameter for all `run` functions is `hooks`:

{% tabs %}
{% tab title="Class-based tasks" %}

```python
# modules/hello_world.py

import prism.task
import prism.target

class HelloWorld(prism.task.PrismTask):
    
    def run(self, tasks, hooks):
        test_str = "Hello, world!"
        return test_str
```

{% endtab %}

{% tab title="Function-based tasks" %}

```python
# modules/hello_world.py

from prism.decorators import task

@task()
def hello_world(tasks, hooks):
    test_str = "Hello, world!"
    return test_str
```

{% endtab %}
{% endtabs %}

This parameter is an instance of the `PrismHooks` class, a high-level interface that lets you quickly and easily talk to external connections without having to write low-level code or use special libraries.

The following hooks are available to Prism users:

* [`hooks.sql()`](https://docs.runprism.com/v0.2.6/fundamentals/tasks/hooks/hooks.sql): execute SQL code using specific adapters
* [`hooks.spark()`](https://docs.runprism.com/v0.2.6/fundamentals/tasks/hooks/hooks.spark): execute PySpark code
* [`hooks.dbt_ref()`](https://docs.runprism.com/v0.2.6/fundamentals/tasks/hooks/hooks.dbt_ref): convert materialized dbt models into Pandas DataFrames
* [`hooks.get_connection()`](https://docs.runprism.com/v0.2.6/fundamentals/tasks/hooks/hooks.get_connection): retrieve the connection instance (for SQL adapters)
* [`hooks.get_cursor()`](https://docs.runprism.com/v0.2.6/fundamentals/tasks/hooks/hooks.get_cursor): retrieve a cursor instance (for SQL adapters)


---

# 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.runprism.com/v0.2.6/fundamentals/tasks/hooks.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.
