> ## Documentation Index
> Fetch the complete documentation index at: https://docs.appsignal.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL Instrumentation

## Installation

> [!NOTE]
>
> 🐍 Don't forget to [install the AppSignal for Python package](https://docs.appsignal.com/python/installation.md) in your application first.

The installation instructions differ based on the PostgreSQL adapter package you are using:

* [`aiopg`](#using-aiopg)
* [`asyncpg`](#using-asyncpg)
* [`psycopg2`](#using-psycopg2)
* [`psycopg`](#using-psycopg) (version 3)

> [!WARNING]
>
> When using [SQLAlchemy](https://docs.appsignal.com/python/instrumentations/sqlalchemy.md), **do not** install these instrumentation packages. The instrumentation for SQLAlchemy will automatically instrument queries to the underlying database. Installing both instrumentation packages will result in duplicate events.

### Using `aiopg`

When using the `aiopg` PostgreSQL adapter package, install the `opentelemetry-instrumentation-aiopg` package. To add it to your project, add the following line to your `requirements.txt` file:

```python Python theme={null}

<PythonDisableInstrumentations />
# requirements.txt
opentelemetry-instrumentation-aiopg
```

### Using `asyncpg`

When using the `asyncpg` PostgreSQL adapter package, install the `opentelemetry-instrumentation-asyncpg` package. To add it to your project, add the following line to your `requirements.txt` file:

```python Python theme={null}
# requirements.txt
opentelemetry-instrumentation-asyncpg
```

### Using `psycopg2`

When using the `psycopg2` PostgreSQL adapter package, install the `opentelemetry-instrumentation-psycopg2` package. To add it to your project, add the following line to your `requirements.txt` file:

```python Python theme={null}
# requirements.txt
opentelemetry-instrumentation-psycopg2
```

### Using `psycopg`

When using the `psycopg` (version 3) PostgreSQL adapter package, install the `opentelemetry-instrumentation-psycopg` package. To add it to your project, add the following line to your `requirements.txt` file:

```python Python theme={null}
# requirements.txt
opentelemetry-instrumentation-psycopg
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.