csvsql fails with misleading error if query and dialect are specified with no connection_string
Created by: chisco50
Behavior If I try to run csvsql with "dialect", "query" and no "connection_string", it will fail with a "The --dialect option is only valid when --db is not specified."
Cause: Given that both "query" and "dialect" are being used, the run enters the following block which sets a default connection_string
# Create an SQLite database in memory if no connection string is specified```
if query and not connection_string:
connection_string = "sqlite:///:memory:"
do_insert = True```
Then, the following block will always raise the error as there is now a connection string and a dialect:
if self.args.dialect and connection_string:
self.argparser.error('The --dialect option is only valid when --db is not specified.')
Suggestion: Refactor the code (csvsql.py). One quick possibility is to call the block that raises the error before the block that sets the default connection string.