Skip to content

Commit

Permalink
Error if --overwrite is combined with --no-create, closes #989
Browse files Browse the repository at this point in the history
  • Loading branch information
James McKinney committed Oct 9, 2018
1 parent 6d280f5 commit a5e792a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion csvkit/utilities/csvsql.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def add_arguments(self):
self.argparser.add_argument('--create-if-not-exists', dest='create_if_not_exists', action='store_true',
help='Create table if it does not exist, otherwise keep going. Only valid when --insert is specified.')
self.argparser.add_argument('--overwrite', dest='overwrite', action='store_true',
help='Drop the table before creating. Only valid when --insert is specified.')
help='Drop the table before creating. Only valid when --insert is specified and --no-create is not specified.')
self.argparser.add_argument('--db-schema', dest='db_schema',
help='Optional name of database schema to create table(s) in.')
self.argparser.add_argument('-y', '--snifflimit', dest='sniff_limit', type=int,
Expand Down Expand Up @@ -86,6 +86,8 @@ def main(self):
self.argparser.error('The --create-if-not-exists option is only valid if --insert is also specified.')
if self.args.overwrite and not self.args.insert:
self.argparser.error('The --overwrite option is only valid if --insert is also specified.')
if self.args.overwrite and self.args.no_create:
self.argparser.error('The --overwrite option is only valid if --no-create is not specified.')
if self.args.before_insert and not self.args.insert:
self.argparser.error('The --before-insert option is only valid if --insert is also specified.')
if self.args.after_insert and not self.args.insert:
Expand Down
3 changes: 2 additions & 1 deletion docs/scripts/csvsql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ Generate SQL statements for a CSV file or execute those statements directly on a
Create table if it does not exist, otherwise keep
going. Only valid when --insert is specified.
--overwrite Drop the table before creating. Only valid when
--insert is specified.
--insert is specified and --no-create is not
specified.
--db-schema DB_SCHEMA
Optional name of database schema to create table(s)
in.
Expand Down

0 comments on commit a5e792a

Please sign in to comment.