You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I'm generating a derived table in python, I often drop the table and create it from scratch. However, the first time I generate the table, it doesn't exist, so the drop raises an exception. That means more boilerplate.
I was going to submit a pull request that adds an "if_exists" option to the drop method of tables and views.
However, for a utility like sqlite_utils, perhaps the "IF EXISTS" SQL semantics is what you want most of the time, and thus should be the default.
What do you think?
The text was updated successfully, but these errors were encountered:
Other methods (db.create_view() for example) have ignore=True to mean "don't throw an error if this causes a problem", so I'm good with adding that to .drop_view().
I don't like using it as the default partly because that would be a very minor breaking API change, but mainly because I don't want to hide mistakes people make - e.g. if you mistype the name of the table you are trying to drop.
sqlite-utils create-view currently has a --ignore option, so adding that to sqlite-utils drop-view and sqlite-utils drop-table makes sense as well.
simonw
changed the title
db["my_table"].drop(ignore=True) parameter
db["my_table"].drop(ignore=True) parameter, plus sqlite-utils drop-table --ignore and drop-view --ignore
Feb 25, 2021
When I'm generating a derived table in python, I often drop the table and create it from scratch. However, the first time I generate the table, it doesn't exist, so the drop raises an exception. That means more boilerplate.
I was going to submit a pull request that adds an "if_exists" option to the
drop
method of tables and views.However, for a utility like sqlite_utils, perhaps the "IF EXISTS" SQL semantics is what you want most of the time, and thus should be the default.
What do you think?
The text was updated successfully, but these errors were encountered: