Skip to content

a simple tool that uses a CSV to populate SQL query parameter markers.

License

Notifications You must be signed in to change notification settings

mccurdyc/query-csv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

a simple tool that uses a CSV to populate SQL query parameter markers.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published