<commit_before># Juttle PostgreSQL Adapter

[![Build Status](https://travis-ci.org/juttle/juttle-postgres-adapter.svg?branch=master)](https://travis-ci.org/juttle/juttle-postgres-adapter)


PostgreSQL adapter for the [Juttle data flow
language](https://github.com/juttle/juttle), with read & write support.

## Examples

Read rows from your `logs` SQL table where the log `level` is `info`, with the
```juttle
read postgres -table 'logs' level = 'info'
```

Perform an equivalent query using the -raw option:

```juttle
read postgres -raw 'select * from "logs" where "level" = "info" limit 10000'
```

Add a `debug` option to return the final SQL query instead (before any pagination):

```juttle
read postgres -table "logs" -debug true level = "info"
```

will output: `{query: 'select * from "logs" where "level" = 'info' limit 10000'}`.

If you have time series data in your table, indicate the column with the
timestamp using the `timeField` option to paginate and sort data correctly:

```juttle
read postgres -timeField "create_time" -table "logs";
read postgres -timeField "create_time" -table "logs -from :2 days ago: -to :1 hour ago:;"
```

The content of the column indicated by `timeField` will appear as the `time`
field in resulting points.

## Installation

Like Juttle itself, the adapter is installed as a npm package. Both Juttle and
the adapter need to be installed side-by-side:

```bash
$ npm install juttle
$ npm install juttle-postgres-adapter
```

## Configuration<commit_msg>Adding a link to demo example<commit_after># Juttle PostgreSQL Adapter

[![Build Status](https://travis-ci.org/juttle/juttle-postgres-adapter.svg?branch=master)](https://travis-ci.org/juttle/juttle-postgres-adapter)


PostgreSQL adapter for the [Juttle data flow
language](https://github.com/juttle/juttle), with read & write support.

## Examples

Read rows from your `logs` SQL table where the log `level` is `info`, with the
```juttle
read postgres -table 'logs' level = 'info'
```

Perform an equivalent query using the -raw option:

```juttle
read postgres -raw 'select * from "logs" where "level" = "info" limit 10000'
```

Add a `debug` option to return the final SQL query instead (before any pagination):

```juttle
read postgres -table "logs" -debug true level = "info"
```

will output: `{query: 'select * from "logs" where "level" = 'info' limit 10000'}`.

If you have time series data in your table, indicate the column with the
timestamp using the `timeField` option to paginate and sort data correctly:

```juttle
read postgres -timeField "create_time" -table "logs";
read postgres -timeField "create_time" -table "logs -from :2 days ago: -to :1 hour ago:;"
```

The content of the column indicated by `timeField` will appear as the `time`
field in resulting points.

An end-to-end example is described [here](https://github.com/juttle/juttle-engine/tree/master/examples/postgres-diskstats) and deployed to the demo system [demo.juttle.io](http://demo.juttle.io/?path=/examples/postgres-diskstats/throughput.juttle).

## Installation

Like Juttle itself, the adapter is installed as a npm package. Both Juttle and
the adapter need to be installed side-by-side:

```bash
$ npm install juttle
$ npm install juttle-postgres-adapter
```

## Configuration
{'fraction_non_alphanumeric': 0.11948529411764706, 'fraction_numerical': 0.007352941176470588, 'mean_word_length': 4.728070175438597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 7, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5138390', 'n_tokens_mistral': 1073, 'n_tokens_neox': 981, 'n_words': 393}