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"