Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning underlying cause for User Defined Functions #300

Closed
wsargent opened this issue Jul 30, 2021 · 1 comment
Closed

Returning underlying cause for User Defined Functions #300

wsargent opened this issue Jul 30, 2021 · 1 comment

Comments

@wsargent
Copy link

The sqlite3 client takes user defined functions and replaces the text with "user-defined function raised exception`" so it's not apparent what's gone wrong:

Unexpected error: user-defined function raised exception

As mentioned in https://code.djangoproject.com/ticket/29500 and https://stackoverflow.com/questions/45824209/how-to-get-an-error-kind-from-sqlite-create-function/45834923#45834923 the workaround for this is to enable callback tracebacks:

sqlite3.enable_callback_tracebacks(True)

It would be nice if https://sqlite-utils.datasette.io/en/stable/python-api.html#registering-custom-sql-functions either included a reference to enable_callback_tracebacks or if registering a user defined function set this flag automatically.

@simonw
Copy link
Owner

simonw commented Aug 2, 2021

I'm nervous to set this by default in the Python library because it's a global setting, so I can't isolate it to just code that is being called by a sqlite_utils method.

The new sqlite-utils convert command from #251 DOES turn it on - I think having it on by default for a CLI tool that uses user-defined functions makes sense:

sqlite3.enable_callback_tracebacks(True)

I like the suggestion to include this in the documentation. I'll do that!

@simonw simonw closed this as completed in ec50e5e Aug 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants