# hooks.get\_cursor(...)

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

* Parameters
  * `adapter_name`: the adapter in the projects [profile YML](https://docs.runprism.com/v0.2.4/fundamentals/config-files/profile-yml) whose connection you want to retrieve
* Returns:
  * A database cursor associated with the adapter's connection

Note that this is only available for the following adapters:

* Postgres
* Redshift
* Snowflake
* Trino

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

```python
from prism.task import PrismTask

class SqlTask(PrismTask)

    def run(self, tasks, hooks):
        with cursor as hooks.get_connection(adapter_name="<ADAPTER_NAME">):
            cursor.execute("...")
        cursor.close()
        return ...

```

{% endtab %}

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

```python
from prism.decorators import task


@task()
def sql_task(tasks, hooks):
    with cursor as hooks.get_connection(adapter_name="<ADAPTER_NAME">):
        cursor.execute("...")
    cursor.close()
    return ...

```

{% endtab %}
{% endtabs %}
