<commit_before><a href="http://promises-aplus.github.com/promises-spec">
    <img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png"
         align="right" valign="top" alt="Promises/A+ logo" />
</a>

pg2json
=======
This module loads postgres meta data and returns it as json.

[![Build Status](https://travis-ci.org/heinzelmannchen/pg2json.png?branch=master)](https://travis-ci.org/heinzelmannchen/heinzelmannchen-template)

Usage
-----

###CLI

1. create a config file:
```javascript
{
    "charset": "utf8",
    "database": "heinzel",
    "host": "127.0.0.1",
    "user": "user",
    "password": "password"
}
```
2. use the cli
```
node bin\cli.js -c configFile -o outputFile
```
use help (-h / -help) for more information
3. select desired table

###Node module
----------
```javascript
var pg2json = require('pg2json');

//1. Setup connection
pg2json.connect({
    charset: 'utf8',
    database: 'test',
    host: '127.0.0.1',
    user: 'user',
    password: 'password'
});

//2. Get tables
console.log(pg2json.getTables());

//3. Get columns
console.log(pg2json.getColumns('tableName'));

//4. Get relations
console.log(pg2json.getRelations('tableName'));
```<commit_msg>promise based<commit_after><a href="http://promises-aplus.github.com/promises-spec">
    <img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png"
         align="right" valign="top" alt="Promises/A+ logo" />
</a>

pg2json
=======
This module loads postgres meta data and returns it as json.

[![Build Status](https://travis-ci.org/heinzelmannchen/pg2json.png?branch=master)](https://travis-ci.org/heinzelmannchen/heinzelmannchen-template)

Usage
-----

###CLI

1. create a config file:
```javascript
{
    "charset": "utf8",
    "database": "heinzel",
    "host": "127.0.0.1",
    "user": "user",
    "password": "password"
}
```
2. use the cli
```
node bin\cli.js -c configFile -o outputFile
```
use help (-h / -help) for more information
3. select desired table

###Node module
----------
```javascript
var pg2json = require('pg2json');

//1. Setup connection
pg2json.connect({
    charset: 'utf8',
    database: 'test',
    host: '127.0.0.1',
    user: 'user',
    password: 'password'
});

//2. Get tables
pg2json.getTables()
    .then(onTablesRead)
    .fail(onError);

//3. Get columns
pg2json.getColumns('tableName')
    .then(onColumnsRead)
    .fail(onError);

//4. Get relations
pg2json.getRelations('tableName')
    .then(onRelationsRead)
    .fail(onError);
```
{'fraction_non_alphanumeric': 0.1957566052842274, 'fraction_numerical': 0.02321857485988791, 'mean_word_length': 3.5853211009174313, 'pattern_counts': {'":': 10, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '7498988', 'n_tokens_mistral': 929, 'n_tokens_neox': 895, 'n_words': 195}