# hooks.get\_connection(...)

`hooks.get_connection(`*`adapter_name: str`*`)`

* Parameters
  * `adapter_name`: the adapter in the projects [profile YML](https://docs.runprism.com/v0.2.0/fundamentals/config-files/profile-yml) whose connection you want to retrieve
* Returns:
  * BigQuery --> [`google.cloud.bigquery.Client`](https://gcloud.readthedocs.io/en/latest/bigquery-client.html)
  * Postgres --> [`psycopg2.Connection`](https://www.psycopg.org/docs/connection.html)
  * Redshift --> [`psycopg2.Connection`](https://www.psycopg.org/docs/connection.html)
  * Snowflake --> [`snowflake.connector.Connection`](https://docs.runprism.com/v0.2.0/fundamentals/tasks/tasks)
  * Trino --> [`trino.dbapi.Connection`](https://github.com/trinodb/trino-python-client)

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

```python
from prism.task import PrismTask

class SqlTask(PrismTask)

    def run(self, tasks, hooks):
        conn = hooks.get_connection(adapter_name="<ADAPTER_NAME">)
        conn.do_stuff()
        return ...

```

{% endtab %}

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

```python
from prism.decorators import task


@task()
def sql_task(tasks, hooks):
    conn = hooks.get_connection(adapter_name="<ADAPTER_NAME">)
    conn.do_stuff()
    return ...

```

{% endtab %}
{% endtabs %}


---

# 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.0/api-reference/prismhooks/hooks.get_connection-....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.
