0.6.3 • Published 4 years ago

csv-to-pg v0.6.3

Weekly downloads
46
License
SEE LICENSE IN LI...
Repository
github
Last release
4 years ago

csv-to-pg Build Status

Create PostgreSQL statements from CSV files

Installation

npm install -g csv-to-pg

Usage

The idea for this library was to solve complex CSV scenarios, so currently each CSV requires a config file.

config

Here is an example of a config.yaml that we can use to parse a csv that has no headers, and uses tab-delimited elements:

input: "./myfile.tsv"
output: "./myfile.sql"
schema: myschema
table: mytable
delimeter: "\t"
headers:   # order of the headers
  - feature
  - category
  - days
  - start
  - end
fields:
  feature: text
  category: text
  days: int
  start: date
  end:
    type: date
    cast: date  # explicitly cast to a date type

You can also use JS files or JSON. If you use JS, you can also create ASTs for super custom inserts (read tests).

run it!

Once you have a config file, simply call it and point to the config:

csv2pg ./config.yaml
0.6.3

4 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.9

5 years ago

0.5.6

5 years ago

0.5.4

5 years ago

0.5.5

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.0

5 years ago

0.5.1

5 years ago

0.0.1

5 years ago