From ec50e5eebc502c85448a2d3db74985c3b0c630c5 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Mon, 2 Aug 2021 14:53:44 -0700 Subject: [PATCH] sqlite3.enable_callback_tracebacks(True) in docs, closes #300 --- docs/python-api.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/python-api.rst b/docs/python-api.rst index c372a62..7ff3727 100644 --- a/docs/python-api.rst +++ b/docs/python-api.rst @@ -2323,6 +2323,18 @@ If you want to deliberately replace the registered function with a new implement def reverse_string(s): return s[::-1] +Exceptions that occur inside a user-defined function default to returning the following error:: + + Unexpected error: user-defined function raised exception + +You can cause ``sqlite3`` to return more useful errors, including the traceback from the custom function, by executing the following before your custom fuctions are executed: + +.. code-block:: python + + from sqlite_utils.utils import sqlite3 + + sqlite3.enable_callback_tracebacks(True) + .. _python_api_quote: Quoting strings for use in SQL