simonw / csvs-to-sqlite

Convert CSV files into a SQLite database
Apache License 2.0
878 stars 69 forks source link

Schema mis-matches in multi-CSV imports into existing databases needs more helpful errors #76

Open warriorstar-orion opened 3 years ago

warriorstar-orion commented 3 years ago

Hello,

Assume I have a sqlite3 database with a table foo, and a file named foo.csv which I'd like to import. The behavior is to add these data into the table with the existing filename, which is what I want. However, let's say foo.csv includes several more columns not in the foo table schema. To figure this out, I have to find out one column at a time: that is, run csvs-to-sqlite foo.csv db.sqlite, wait for it to spit out an error such as sqlite3.OperationalError: table foo has no column named bar, add that column to foo.csv, and try again, for each column missing in the schema.

A --dry-run option that lets one know of these schema mis-matches, all of them, ahead of time, would be incredibly helpful.

Thanks!