<!-- review: finished -->

<a id="external-postgres"></a>

# Postgres

Модуль Postgres обеспечивает непосредственную поддержку баз данных PostgreSQL.

<a id="installation-22"></a>

## Установка

Для [установки](https://angie.software//angie/docs/installation/index.md#install-packages) модуля используйте один из следующих пакетов:

- Angie: `angie-module-postgres`;
- Angie PRO: `angie-pro-module-postgres`.

<a id="loading-the-module-22"></a>

## Загрузка модуля

Подключение модуля в контексте `main{}`:

```nginx
load_module modules/ngx_postgres_module.so;
```

<a id="configuration-example-96"></a>

## Пример конфигурации

```nginx
http {
    upstream database {
        postgres_server 127.0.0.1 dbname=ang_test
                         user=ang_test password=ang_test;
    }

    server {
        listen 80;
        postgres_output text;

        location /create {
            postgres_pass database;
            postgres_query "CREATE TABLE cats (id integer, name text)";
        }

        location /insert {
            postgres_pass database;
            postgres_query "INSERT INTO cats (id, name) VALUES ($arg_id, '$arg_name')";
        }

        location /select {
            postgres_pass database;
            postgres_query "SELECT name FROM cats WHERE id=$arg_id";
        }
    }
}
```

<a id="additional-information-23"></a>

## Дополнительная информация

Подробная документация и исходный код доступны по ссылке:
[https://github.com/FRiCKLE/ngx_postgres](https://github.com/FRiCKLE/ngx_postgres)
