simonw / sqlite-utils

Python CLI utility and library for manipulating SQLite databases
https://sqlite-utils.datasette.io
Apache License 2.0
1.68k stars 112 forks source link

create_view(..., ignore=True, replace=True) parameters #106

Closed simonw closed 4 years ago

simonw commented 4 years ago

Two new parameters which specify what should happen if the view already exists. I want this for https://github.com/dogsheep/github-to-sqlite/issues/37

Here's the current create_view() implementation:

https://github.com/simonw/sqlite-utils/blob/b4d953d3ccef28bb81cea40ca165a647b59971fa/sqlite_utils/db.py#L325-L332

ignore=True will not do anything if the view exists already.

replace=True will drop and redefine the view - but only if its SQL definition differs, otherwise it will be left alone.

simonw commented 4 years ago

Docs: https://sqlite-utils.readthedocs.io/en/latest/python-api.html#creating-views