csvkit icon indicating copy to clipboard operation
csvkit copied to clipboard

sql2csv: Support for bind parameters

Open cfh294 opened this issue 6 years ago • 1 comments

It would be great to be able to pass in bind parameters for parameterized queries when using sql2csv. Something along the lines of:

query.sql

select * from phone_book where last_name=:p_last_name;

Script:

sql2csv query.sql -b "p_last_name='Jones'" --db <connection string>

cfh294 avatar Nov 19 '19 14:11 cfh294

It seems like it can be done that way, it worked for me:

CATEGORIES=(table1 table2 table3)

for i in "${CATEGORIES[@]}"
do
   :
   sql2csv --db <connection string> --query "SELECT * FROM v_${i}" > csv/$i
done

Not exactly the same process but maybe it'll help someone else.

IdrissaD avatar Jun 22 '21 09:06 IdrissaD