pgimport
Import data from file to PostgreSQL database.
Last updated 3 years ago by zand3rs .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install pgimport 
SYNC missed versions from official npm registry.

pgimport

Import data from file to PostgreSQL database.

Installation

$ npm install pgimport -g

Usage

$ pgimport

  Usage: pgimport [options]

  Options:

    -h, --help                     output usage information
    -v, --version                  output the version number
    --connect <connect>            Db connection string
    --from <from>                  Source folder or file
    --to <to>                      Destination table
    --local-dir <local_dir>        Local directory where remote files are synced, default=/tmp/pgimport
    --access-key <access_key>      AWS access key
    --secret-key <secret_key>      AWS secret key
    --ignore-attrs <attrs_list>    Ignore attributes
    --map <map_file>               File path containing the attribute/field mapping
    -p, --processors <processors>  Number of processors, default=1
    -r, --recursive [true|false]   Recursive copy, default=false
    -f, --force [true|false]       Non-interactive, default=false
    -d, --debug [true|false]       Show debug messages, default=false


$ pgimport --connect='user@localhost' --to='public.logs' --from='/path/to/file.log'
$ pgimport --connect='user@localhost' --to='public.logs' --from='/path/to/file.log.gz'
$ pgimport --connect='user@localhost' --to='public.logs' --from='s3://bucket/folder' -r -f

File Format

Data records should be in a valid JSON format. Each line represents a row in the database table with JSON attribute names as column names.

$ cat sample.log
{ "ts":"2017-06-01T01:14:09Z", "event":"pageview", "url":"http://www.abc.com" }
{ "ts":"2017-06-01T01:39:51Z", "event":"pageview", "url":"http://www.def.com" }
{ "ts":"2017-06-01T02:11:47Z", "event":"pageview", "url":"http://www.ghi.com" }

Database Connection String

The general form for a connection string:

[user[:password]@][netloc][:port][/dbname][?param1=value1&...]

Examples:

localhost
localhost:5433
localhost/mydb
user@localhost
user:secret@localhost
other@localhost/otherdb?connect_timeout=10

Current Tags

  • 0.0.6                                ...           latest (3 years ago)

7 Versions

  • 0.0.6                                ...           3 years ago
  • 0.0.5                                ...           3 years ago
  • 0.0.4                                ...           3 years ago
  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
  • 0.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 9
This Month 2
Last Day 0
Last Week 1
Last Month 9
Dependencies (11)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |