<!-- review: finished -->

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

# Postgres

The Postgres module provides direct support for PostgreSQL databases.

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

## Installation

To [install](https://en.angie.software//angie/docs/installation/index.md#install-packages) the module, use one of the following packages:

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

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

## Loading the Module

Load the module in the `main{}` context:

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

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

## Configuration Example

```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>

## Additional Information

Detailed documentation and source code are available at:
[https://github.com/FRiCKLE/ngx_postgres](https://github.com/FRiCKLE/ngx_postgres)
