querycsv-redux icon indicating copy to clipboard operation
querycsv-redux copied to clipboard

Error when file name contains dashes.

Open ifigueroap opened this issue 9 years ago • 2 comments

I got the following exception trace when doing:

./querycsv.py -i injectorLog-23894-eager.csv -o failures-23894-eager.log "SELECT * FROM injectorLog-23894-eager WHERE status == \\"FAILURE\\""
Traceback (most recent call last):
  File "./querycsv.py", line 307, in <module>
    qcsv(csvfiles, outfile, file_db, keep_db, sqlcmd)
  File "./querycsv.py", line 211, in qcsv
    csv_to_sqldb(conn, csvfile, tablename)
  File "./querycsv.py", line 156, in csv_to_sqldb
    sqldb.execute("create table %s (%s);" % (table_name, colstr))
sqlite3.OperationalError: near "-": syntax error

The issue went away when after I replaced the dashes with underscores. Perhaps a warning can be included, or at least some comment in the documentation?

Thanks for the cool tool!

ifigueroap avatar Sep 23 '15 20:09 ifigueroap

Good idea. I have run into this problem before when file names do not represent valid SQL table names. Thanks!

kdeloach avatar Sep 24 '15 02:09 kdeloach

Perhaps it is even better to handle this issue in a way transparent to the user. That is, perform a "normalization" step for the names of the file/table so from the client point of view you don't have to care about special cases.

ifigueroap avatar Sep 24 '15 13:09 ifigueroap