Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when file name contains dashes. #20

Open
ifigueroap opened this issue Sep 23, 2015 · 2 comments
Open

Error when file name contains dashes. #20

ifigueroap opened this issue Sep 23, 2015 · 2 comments

Comments

@ifigueroap
Copy link

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!

@kdeloach
Copy link
Owner

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

@ifigueroap
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants