sqlite-utils convert can now use callable references, closes #686

This now works:

    echo '{"date": "13th January 2025"}' | sqlite-utils insert dates.db dates -
    sqlite-utils convert dates.db dates date r.parsedate
    sqlite-utils rows dates.db dates

Previously the command would have been:

    sqlite-utils convert dates.db dates date 'r.parsedate(value)'
This commit is contained in:
Simon Willison 2025-11-29 14:43:02 -08:00 committed by GitHub
commit 5a7f522980
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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