mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
sqlite-utils convert db table column -, refs #353
This commit is contained in:
parent
e328db8eba
commit
a3df483c80
3 changed files with 48 additions and 0 deletions
|
|
@ -2038,6 +2038,8 @@ def _generate_convert_help():
|
|||
|
||||
"value" is a variable with the column value to be converted.
|
||||
|
||||
Use "-" for CODE to read Python code from standard input.
|
||||
|
||||
The following common operations are available as recipe functions:
|
||||
"""
|
||||
).strip()
|
||||
|
|
@ -2120,6 +2122,9 @@ def convert(
|
|||
raise click.ClickException("Cannot use --multi with more than one column")
|
||||
if drop and not (output or multi):
|
||||
raise click.ClickException("--drop can only be used with --output or --multi")
|
||||
if code == "-":
|
||||
# Read code from standard input
|
||||
code = sys.stdin.read()
|
||||
# If single line and no 'return', add the return
|
||||
if "\n" not in code and not code.strip().startswith("return "):
|
||||
code = "return {}".format(code)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue