query-csv

command module
v0.0.0-...-fd54af9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2019 License: GPL-3.0 Imports: 10 Imported by: 0

README

query-csv

USE AT YOUR OWN RISK

query-csv is a simple tool that uses a CSV to populate SQL query parameters.

Getting Started

Requirements
  • Go
Installing
go get github.com/mccurdyc/query-csv

Usage

Make sure that your connection string and query follow the requirements for the chosen database driver. For example, with the PostgreSQL driver, the connection string and query parameters should follow that outlined in the Supported Database Drivers section.

BE CAREFUL

Example
make build
./bin/query \
  --file=<path/to/csv> \
  --conn_str="user=<username> password=<password> dbname=<dbname> host=<db-host> port=<db-port> sslmode=disable search_path=<search-path>" \
  --db_driver="postgres" \
  --query="UPDATE table_a SET b_id = b.id FROM (SELECT id FROM table_b WHERE field = \$2) AS b WHERE a.some_field = \$1"

Supported Database Drivers

postgres
sqlite

TODOs

  • help menu
  • handle CSV header line nicely.
  • make it clear somewhere that values in CSV must line up to query parameters.

License

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL