diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index 1e31088..b235068 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -791,7 +791,7 @@ def insert_upsert_implementation( else: try: if nl: - docs = (json.loads(line) for line in decoded) + docs = (json.loads(line) for line in decoded if line.strip()) else: docs = json.load(decoded) if isinstance(docs, dict): diff --git a/tests/test_cli_insert.py b/tests/test_cli_insert.py index 9c218cc..c40dd85 100644 --- a/tests/test_cli_insert.py +++ b/tests/test_cli_insert.py @@ -165,7 +165,7 @@ def test_insert_newline_delimited(db_path): result = CliRunner().invoke( cli.cli, ["insert", db_path, "from_json_nl", "-", "--nl"], - input='{"foo": "bar", "n": 1}\n{"foo": "baz", "n": 2}', + input='{"foo": "bar", "n": 1}\n\n{"foo": "baz", "n": 2}', ) assert 0 == result.exit_code, result.output db = Database(db_path)