mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-02 07:24:21 +02:00
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:
parent
f9e5fbb3bd
commit
29b07222f5
3 changed files with 74 additions and 3 deletions
14
docs/cli.rst
14
docs/cli.rst
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue