mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 10:24:32 +02:00
--convert --text for iterators, docs for --convert
This commit is contained in:
parent
2e4847e493
commit
413f8ed754
3 changed files with 136 additions and 13 deletions
|
|
@ -396,6 +396,26 @@ def test_insert_convert_text(db_path):
|
|||
assert rows == [{"text": "THIS IS TEXT\nWILL BE UPPER NOW"}]
|
||||
|
||||
|
||||
def test_insert_convert_text_returning_iterator(db_path):
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
[
|
||||
"insert",
|
||||
db_path,
|
||||
"text",
|
||||
"-",
|
||||
"--text",
|
||||
"--convert",
|
||||
'({"word": w} for w in text.split())',
|
||||
],
|
||||
input="A bunch of words",
|
||||
)
|
||||
assert result.exit_code == 0, result.output
|
||||
db = Database(db_path)
|
||||
rows = list(db.query("select [word] from [text]"))
|
||||
assert rows == [{"word": "A"}, {"word": "bunch"}, {"word": "of"}, {"word": "words"}]
|
||||
|
||||
|
||||
def test_insert_convert_lines(db_path):
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue