Added table.delete(pk) method, refs #62

This commit is contained in:
Simon Willison 2019-11-04 08:07:44 -08:00
commit 19073d6d97
3 changed files with 39 additions and 0 deletions

View file

@ -382,6 +382,20 @@ You can cause any missing columns to be added automatically using ``alter=True``
>>> db["dogs"].update(1, {"breed": "Mutt"}, alter=True)
.. _python_api_delete:
Deleting a specific record
==========================
You can delete a record using ``table.delete()``::
>>> db = sqlite_utils.Database("dogs.db")
>>> db["dogs"].delete(1)
The ``delete()`` method takes the primary key of the record. This can be a tuple of values if the row has a compound primary key::
>>> db["compound_dogs"].delete((5, 3))
Upserting data
==============