tsvsql: Template tsv into SQL

[ mit, program, text ] [ Propose Tags ]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 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 by DanielChoi at 2016-07-09T19:47:30Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables tsvsql
Downloads 1756 total (7 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2016-11-22 [all 3 reports]

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.