Name

ngx_rds_csv - Nginx output filter module to convert Resty-DBD-Streams (RDS) to Comma-Separated Values (CSV)

Table of Contents

Status

This module is considered production ready.

Synopsis

location /foo {
    # drizzle_pass/postgres_pass/...

    rds_csv on;
    rds_csv_row_terminator "\n"; # default to "\r\n"
}

Description

This module implements an efficient output filter that converts Resty-DBD-Streams (RDS) generated by ngx_drizzle and ngx_postgres to Comma-Separated Values (CSV) format in a streaming fashion. By default, the CSV format is in compliance with RFC 4180:

http://tools.ietf.org/html/rfc4180

SQL NULL values will be converted to empty field value, just like empty string values.

Back to TOC

Directives

Back to TOC

rds_csv

syntax: rds_csv on|off

default: rds_csv off

context: http, server, location, location if

Enables this output filter when on and disables otherwise.

Back to TOC

rds_csv_row_terminator

syntax: rds_csv_row_terminator <str>

default: rds_csv_row_terminator "\r\n"

context: http, server, location, location if

Specifies the row terminator used by the CSV format. Only "\r\n" and "\n" are allowed.

Defaults to "\r\n", i.e., CR LF, according to RFC 4180.

Back to TOC

rds_csv_field_separator

syntax: rds_csv_field_separator <char>

default: rds_csv_field_separator ","

context: http, server, location, location if

Specifies the field seperator used by the CSV format. Only ",", ";", and "\t" are allowed.

Defaults to "," according to RFC 4180.

Back to TOC

rds_csv_field_name_header

syntax: rds_csv_field_name_header on|off

default: rds_csv_field_name_header off

context: http, server, location, location if

Emits the first line of field names when this directive is set on, and none otherwise.

Back to TOC

rds_csv_content_type

syntax: rds_csv_content_type <str>

default: rds_csv_content_type "text/csv; header=<present|absence>"

context: http, server, location, location if

Specifies the Content-Type response header generated by this module.

Defaults to "text/csv; header=present" or "text/csv; header=absence", depending on whether rds_csv_field_name_header is on or off.

Back to TOC

rds_csv_buffer_size

syntax: rds_csv_buffer_size <size>

default: rds_csv_buffer_size 4k/8k

context: http, server, location, location if

The lager this buffer size setting, the less streammy the output will be.

Back to TOC

Installation

You're recommended to install this module (as well as the Nginx core and many other goodies) via the ngx_openresty bundle. See the detailed instructions for downloading and installing ngx_openresty into your system. This is the easiest and most safe way to set things up.

Alternatively, you can install this module manually with the Nginx source:

Grab the nginx source code from nginx.org, for example, the version 1.9.7 (see nginx compatibility), and then build the source with this module:

 $ wget 'http://nginx.org/download/nginx-1.9.7.tar.gz'
 $ tar -xzvf nginx-1.9.7.tar.gz
 $ cd nginx-1.9.7/

 # Here we assume you would install you nginx under /opt/nginx/.
 $ ./configure --prefix=/opt/nginx \
     --add-module=/path/to/rds-csv-nginx-module

 $ make -j2
 $ make install

Download the latest version of the release tarball of this module from rds-csv-nginx-module file list.

Also, this module is included and enabled by default in the ngx_openresty bundle.

Back to TOC

Compatibility

This module is compatible with the following versions of Nginx:

Back to TOC

Author

Yichun "agentzh" Zhang <agentzh@gmail.com>, CloudFlare Inc.

Back to TOC

Copyright & License

This module is licenced under the BSD license.

Copyright (C) 2011-2016, Yichun "agentzh" Zhang (章亦春) <agentzh@gmail.com>, CloudFlare Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Back to TOC

See Also

Back to TOC