csvsql: Add --unique-index a,b to add unique index
Created by: brandon-rhodes
It is wonderful that --insert
exists and provides a quick way to have a table created and loaded with data!
But if the source CSV file is improved, tweaked, or regenerated, then the user is dead in the water. The table in the database is now out of sync with the CSV data, and there is no facility for ever updating it. There are at least two ways that csvkit could solve this:
- Provide a
--drop
option that would, in a single database transaction, drop the table, create the table, and reload it with the new data. - The really fun solution would be an
--upsert COLUMN[,COLUMN...]
option that attempted to insert all of the rows, but for those that failed switched to attempting an update using the given columns as keys to search for and match.