The tsvsql package

[ Tags: mit, program, text ] [ Propose Tags ]

[Skip to Readme]

Properties

Versions 0.1.1.0, 0.2.0.0, 0.2.1.0
Dependencies attoparsec, base (>=4.6 && <4.9), bytestring, containers, optparse-applicative, string-qq, text (>=1.1.0.0), unordered-containers [details]
License MIT
Author Daniel Choi
Maintainer dhchoi@gmail.com
Category Text
Home page https://github.com/danchoi/tsvsql
Uploaded Sat Jul 9 19:47:30 UTC 2016 by DanielChoi
Distributions NixOS:0.2.1.0
Executables tsvsql
Downloads 258 total (10 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-11-22 [all 3 reports]
Hackage Matrix CI

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for tsvsql-0.2.1.0

[back to package description]
tsvsql

Templates TSV values into a SQL template

input.tsv:
apple 1
banana 2

tsvsql $ < input.tsv dist/build/tsvsql/tsvsql 'INSERT into fruits (name, price) VALUES ($1, $2:num);'
INSERT into fruits (name, price) VALUES ('apple', 1);
INSERT into fruits (name, price) VALUES ('banana', 2);


WARNING: Use single quotes around the SQL template expression so that
Bash does not do interpolation.

'null' text is translated into NULL:

input2.tsv
apple	1
banana	null

tsvsql $ < input2.tsv dist/build/tsvsql/tsvsql 'INSERT into fruits (name, price) VALUES ($1, $2:num);'
INSERT into fruits (name, price) VALUES ('apple', 1);
INSERT into fruits (name, price) VALUES ('banana', NULL);

The subtitution placeholders are like this:

    $1      # value is a string; the value is quoted and escaped
    $2:num  # value is a number; not quoted
    $3:bool # value is a bool; "t" and "1" are true, "f" and "0" are false

The placeholders start counting the first TSV value from position 1, not
zero.