Postgres#

The Postgres module provides direct support for PostgreSQL databases.

Loading the Module#

Connecting the module in the context of main{}:

load_module modules/ngx_postgres_module.so;

Configuration Example#

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";
        }
    }
}

Additional Information#

Detailed documentation and source code are available at: FRiCKLE/ngx_postgres