Allow callable references in sqlite-utils convert, closes #686

This allows users to pass just a callable reference like `r.parsedate`
instead of `r.parsedate(value)` to the convert command. The code now
detects when the input evaluates to a callable and uses it directly.

Examples that now work:
- sqlite-utils convert my.db table col r.parsedate
- sqlite-utils convert my.db table col json.loads --import json
This commit is contained in:
Claude 2025-11-29 20:33:27 +00:00
commit 29b07222f5
No known key found for this signature in database
3 changed files with 74 additions and 3 deletions

View file

@ -1849,7 +1849,19 @@ These recipes can be used in the code passed to ``sqlite-utils convert`` like th
sqlite-utils convert my.db mytable mycolumn \
'r.jsonsplit(value)'
To use any of the documented parameters, do this:
You can also pass the recipe function directly without the ``(value)`` part - sqlite-utils will detect that it is a callable and use it automatically:
.. code-block:: bash
sqlite-utils convert my.db mytable mycolumn r.parsedate
This shorter syntax works for any callable, including functions from imported modules:
.. code-block:: bash
sqlite-utils convert my.db mytable mycolumn json.loads --import json
To use any of the documented parameters, use the full function call syntax:
.. code-block:: bash