mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-24 09:54:31 +02:00
--functions can take filenames, can be used multiple times (#681)
Closes #659 The --functions option now accepts: - File paths ending in .py (e.g., --functions my_funcs.py) - Multiple invocations (e.g., --functions foo.py --functions 'def bar(): ...') - Inline Python code (existing behavior) Implementation follows the same pattern as llm's --functions flag (simonw/llm@a880c123). Changes: - Added multiple=True to --functions Click option in query, bulk, and memory commands - Modified _register_functions() to detect and read .py files - Updated _maybe_register_functions() to iterate over multiple function sources - Removed unused bytes/bytearray handling - Added comprehensive tests for file paths and multiple invocations - Updated documentation with examples 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Shorter help for --functions --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
7aca26267f
commit
638b8ca871
6 changed files with 166 additions and 9 deletions
|
|
@ -131,7 +131,7 @@ See :ref:`cli_query`.
|
|||
-r, --raw Raw output, first column of first row
|
||||
--raw-lines Raw output, first column of each row
|
||||
-p, --param <TEXT TEXT>... Named :parameters for SQL query
|
||||
--functions TEXT Python code defining one or more custom SQL
|
||||
--functions TEXT Python code or file path defining custom SQL
|
||||
functions
|
||||
--load-extension TEXT Path to SQLite extension, with optional
|
||||
:entrypoint
|
||||
|
|
@ -174,7 +174,7 @@ See :ref:`cli_memory`.
|
|||
sqlite-utils memory animals.csv --schema
|
||||
|
||||
Options:
|
||||
--functions TEXT Python code defining one or more custom SQL
|
||||
--functions TEXT Python code or file path defining custom SQL
|
||||
functions
|
||||
--attach <TEXT FILE>... Additional databases to attach - specify alias and
|
||||
filepath
|
||||
|
|
@ -374,7 +374,7 @@ See :ref:`cli_bulk`.
|
|||
|
||||
Options:
|
||||
--batch-size INTEGER Commit every X records
|
||||
--functions TEXT Python code defining one or more custom SQL functions
|
||||
--functions TEXT Python code or file path defining custom SQL functions
|
||||
--flatten Flatten nested JSON objects, so {"a": {"b": 1}} becomes
|
||||
{"a_b": 1}
|
||||
--nl Expect newline-delimited JSON
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue