---
title: Asyncpg
source: https://docs.newrelic.com/docs/apm/agents/python-agent/async-instrumentation/asyncpg
---

The Python agent supports recording database transactions when using the [`asyncpg`](https://pypi.org/project/asyncpg/) database client module for [PostgresSQL](https://www.postgresql.org/). This feature captures timing of database queries, SQL statements for the database query, and a stack trace for long database queries.

Read about the requirements and tips for integrating our Python agent with an app that uses [`asyncpg`](https://pypi.org/project/asyncpg/). To return to the general install instructions, go to [Install the Python agent](https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-installation).

## Automatic initialization with admin script [#wrapper-script]

If you start your app with `python app.py` and use our Python agent **version 5.20.0.149** or higher, you can use the recommended [admin script integration method](https://docs.newrelic.com/docs/agents/python-agent/installation-configuration/python-agent-installation#integration) For example:

```sh
NEW_RELIC_CONFIG_FILE=path/to/newrelic.ini newrelic-admin run-program python path_to_app
```

## Using the Python agent API [#api]

You can use the [Python agent API](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api) to monitor any ASGI server or framework. To do this, mark the [ASGI application entry point](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/asgiapplication-python-agent-api) and set the [transaction names](https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/settransactionname-python-agent-api).

## Event loop diagnostic support [#event-loops]

Our Python agent supports `asyncio` event loop diagnostics. For more information, see [Python event loop diagnostics](https://docs.newrelic.com/docs/agents/python-agent/supported-features/python-event-loop-diagnostics).
