From 43f1c6ab4e3a6b76531fb6f5447adb83d26f3971 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Fri, 6 Mar 2020 15:08:21 -0600 Subject: [PATCH] Documentation for NotFoundError --- docs/python-api.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/python-api.rst b/docs/python-api.rst index 878752a..1b2a2c5 100644 --- a/docs/python-api.rst +++ b/docs/python-api.rst @@ -122,6 +122,17 @@ If the table has a compound primary key you can pass in the primary key values a >>> db["compound_dogs"].get(("mixed", 3)) +If the record does not exist a ``NotFoundError`` will be raised: + +.. code-block:: python + + from sqlite_utils.db import NotFoundError + + try: + row = db["dogs"].get(5) + except NotFoundError: + print("Dog not found") + Creating tables ===============