mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 01:44:31 +02:00
replace=True and ignore=True parameters for create_view(), closes #106
This commit is contained in:
parent
b4d953d3cc
commit
5c1df4e306
4 changed files with 70 additions and 15 deletions
|
|
@ -879,6 +879,16 @@ The ``.create_view()`` method on the database class can be used to create a view
|
|||
select * from dogs where is_good_dog = 1
|
||||
""")
|
||||
|
||||
This will raise a ``sqlite_utils.utils.OperationalError`` if a view with that name already exists.
|
||||
|
||||
You can pass ``ignore=True`` to silently ignore an existing view and do nothing, or ``replace=True`` to replace an existing view with a new definition if your select statement differs from the current view:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
db.create_view("good_dogs", """
|
||||
select * from dogs where is_good_dog = 1
|
||||
""", replace=True)
|
||||
|
||||
Storing JSON
|
||||
============
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue